EqualityVerifier

Verifies whether objects/variable are equal to an expected value


Class: $.HelloWorldIT

InternalCallVerifier EqualityVerifier 
@Test public void testPing() throws Exception { WebClient client=WebClient.create(endpointUrl + "/hello/echo/SierraTangoNevada"); Response r=client.accept("text/plain").get(); assertEquals(Response.Status.OK.getStatusCode(),r.getStatus()); String value=IOUtils.toString((InputStream)r.getEntity()); assertEquals("SierraTangoNevada",value); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testJsonRoundtrip() throws Exception { List providers=new ArrayList(); providers.add(new org.codehaus.jackson.jaxrs.JacksonJsonProvider()); JsonBean inputBean=new JsonBean(); inputBean.setVal1("Maple"); WebClient client=WebClient.create(endpointUrl + "/hello/jsonBean",providers); Response r=client.accept("application/json").type("application/json").post(inputBean); assertEquals(Response.Status.OK.getStatusCode(),r.getStatus()); MappingJsonFactory factory=new MappingJsonFactory(); JsonParser parser=factory.createJsonParser((InputStream)r.getEntity()); JsonBean output=parser.readValueAs(JsonBean.class); assertEquals("Maple",output.getVal2()); }

Class: $.HelloWorldImplTest

InternalCallVerifier EqualityVerifier 
@Test public void testSayHi(){ HelloWorldImpl helloWorldImpl=new HelloWorldImpl(); String response=helloWorldImpl.sayHi("Sam"); assertEquals("HelloWorldImpl not properly saying hi","Hello Sam",response); }

Class: $.HelloWorldPortTypeImplTest

InternalCallVerifier EqualityVerifier 
@Test public void testSayHi(){ HelloWorldPortTypeImpl helloWorldPortTypeImpl=new HelloWorldPortTypeImpl(); String response=helloWorldPortTypeImpl.sayHi("Sam"); assertEquals("HelloWorldPortTypeImpl not properly saying hi","Hello Sam",response); }

Class: demo.hw.server.HelloWorldImplTest

InternalCallVerifier EqualityVerifier 
@Test public void testGetUsers(){ HelloWorldImpl hwi=new HelloWorldImpl(); User mike=new UserImpl("Mike"); hwi.sayHiToUser(mike); User george=new UserImpl("George"); hwi.sayHiToUser(george); Map userMap=hwi.getUsers(); assertEquals("getUsers() not returning expected number of users",userMap.size(),2); assertEquals("Expected user Mike not found","Mike",userMap.get(1).getName()); assertEquals("Expected user George not found","George",userMap.get(2).getName()); }

InternalCallVerifier EqualityVerifier 
@Test public void testSayHiToUser(){ HelloWorldImpl hwi=new HelloWorldImpl(); User sam=new UserImpl("Sam"); String response=hwi.sayHiToUser(sam); assertEquals("SayHiToUser isn't returning expected string","Hello Sam",response); }

InternalCallVerifier EqualityVerifier 
@Test public void testSayHi(){ HelloWorldImpl hwi=new HelloWorldImpl(); String response=hwi.sayHi("Bob"); assertEquals("SayHi isn't returning expected string","Hello Bob",response); }

Class: org.apache.cxf.aegis.client.ClientServiceConfigTest

EqualityVerifier 
@Test public void talkToJaxWsHolder() throws Exception { JaxWsProxyFactoryBean factory=new JaxWsProxyFactoryBean(); factory.setDataBinding(new AegisDatabinding()); factory.setAddress("local://JaxWsEcho"); Echo client=factory.create(Echo.class); Holder sholder=new Holder(); client.echo("Channa Doll",sholder); assertEquals("Channa Doll",sholder.value); }

InternalCallVerifier EqualityVerifier 
@Test public void ordinaryParamNameTest() throws Exception { ClientProxyFactoryBean proxyFac=new ClientProxyFactoryBean(); ReflectionServiceFactoryBean factory=new ReflectionServiceFactoryBean(); proxyFac.setServiceFactory(factory); proxyFac.setDataBinding(new AegisDatabinding()); proxyFac.setAddress("local://Echo"); proxyFac.setBus(getBus()); Echo echo=proxyFac.create(Echo.class); String boing=echo.simpleEcho("reflection"); assertEquals("reflection",boing); }

Class: org.apache.cxf.aegis.inheritance.intf.InterfaceInheritanceTest

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testClient() throws Exception { ClientProxyFactoryBean proxyFac=new ClientProxyFactoryBean(); proxyFac.setAddress("local://IInterfaceService"); proxyFac.setBus(getBus()); setupAegis(proxyFac.getClientFactoryBean()); IInterfaceService client=proxyFac.create(IInterfaceService.class); IChild child=client.getChild(); assertNotNull(child); assertEquals("child",child.getChildName()); assertEquals("parent",child.getParentName()); IParent parent=client.getChildViaParent(); assertEquals("parent",parent.getParentName()); assertFalse(parent instanceof IChild); IGrandChild grandChild=client.getGrandChild(); assertEquals("parent",grandChild.getParentName()); Document wsdl=getWSDLDocument("IInterfaceService"); assertValid("//xsd:complexType[@name='IGrandChild']",wsdl); assertValid("//xsd:complexType[@name='IGrandChild']//xsd:element[@name='grandChildName']",wsdl); assertValid("//xsd:complexType[@name='IGrandChild']//xsd:element[@name='childName'][1]",wsdl); assertInvalid("//xsd:complexType[@name='IGrandChild']//xsd:element[@name='childName'][2]",wsdl); assertValid("//xsd:complexType[@name='IChild']",wsdl); assertValid("//xsd:complexType[@name='IParent']",wsdl); assertInvalid("//xsd:complexType[@name='IChild'][@abstract='true']",wsdl); }

Class: org.apache.cxf.aegis.integration.DOMMappingTest

InternalCallVerifier EqualityVerifier 
@Test public void testSimpleString() throws Exception { String s=docClient.simpleStringReturn(); assertEquals("simple",s); }

InternalCallVerifier EqualityVerifier 
@Test public void testDocService() throws Exception { Document doc=docClient.returnDocument(); Element rootElement=doc.getDocumentElement(); assertEquals("carrot",rootElement.getNodeName()); }

InternalCallVerifier EqualityVerifier 
@Test public void testBeanCases() throws Exception { BeanWithDOM bwd=docClient.getBeanWithDOM(); Element rootElement=bwd.getDocument().getDocumentElement(); assertEquals("carrot",rootElement.getNodeName()); }

Class: org.apache.cxf.aegis.integration.WrappedTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@org.junit.Ignore @Test public void testSubmitJDOMArray() throws Exception { org.jdom.xpath.XPath jxpathWalrus=org.jdom.xpath.XPath.newInstance("/a:anyType/iam:walrus"); jxpathWalrus.addNamespace("a","urn:Array"); jxpathWalrus.addNamespace("iam","uri:iam"); jxpathWalrus.addNamespace("linux","uri:linux"); jxpathWalrus.addNamespace("planets","uri:planets"); invoke("Array","/org/apache/cxf/aegis/integration/anyTypeArrayJDOM.xml"); assertEquals("before items",arrayService.getBeforeValue()); assertEquals(3,arrayService.getJdomArray().length); org.jdom.Element e=(org.jdom.Element)jxpathWalrus.selectSingleNode(arrayService.getJdomArray()[0]); assertNotNull(e); assertEquals("tusks",e.getText()); assertEquals("after items",arrayService.getAfterValue()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testArrayWsdl() throws Exception { NodeList stuff=assertValid("//xsd:complexType[@name='ArrayOfString-2-50']",arrayWsdlDoc); assertEquals(1,stuff.getLength()); }

InternalCallVerifier EqualityVerifier 
@Test public void testSubmitW3CArray() throws Exception { addNamespace("a","urn:Array"); addNamespace("iam","uri:iam"); addNamespace("linux","uri:linux"); addNamespace("planets","uri:planets"); invoke("Array","/org/apache/cxf/aegis/integration/anyTypeArrayW3C.xml"); assertEquals("before items",arrayService.getBeforeValue()); assertEquals(3,arrayService.getW3cArray().length); org.w3c.dom.Document e=arrayService.getW3cArray()[0]; assertValid("/iam:walrus",e); assertEquals("after items",arrayService.getAfterValue()); }

EqualityVerifier 
@Test public void testXmlConfigurationOfParameterType() throws Exception { invoke("Array","takeNumber.xml"); assertEquals(Long.valueOf(123456789),arrayService.getNumberValue()); }

Class: org.apache.cxf.aegis.namespaces.ExplicitPrefixTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testOnePrefix() throws Exception { Map mappings=new HashMap(); mappings.put(URN_AEGIS_NAMESPACE_TEST,AEGIS_TEST_NAMESPACE_PREFIX_XYZZY); ServiceAndMapping serviceAndMapping=setupService(NameServiceImpl.class,mappings); Definition def=getWSDLDefinition("NameServiceImpl"); StringWriter wsdlSink=new StringWriter(); WSDLFactory.newInstance().newWSDLWriter().writeWSDL(def,wsdlSink); org.w3c.dom.Document wsdlDoc=getWSDLDocument("NameServiceImpl"); Element rootElement=wsdlDoc.getDocumentElement(); addNamespace(AEGIS_TEST_NAMESPACE_PREFIX_XYZZY,URN_AEGIS_NAMESPACE_TEST); assertXPathEquals("//namespace::xyzzy",URN_AEGIS_NAMESPACE_TEST,rootElement); Element nameSchema=(Element)assertValid("//xsd:schema[@targetNamespace='urn:aegis:namespace:test']",rootElement).item(0); Map namePrefixes=getNodeNamespaceDeclarations(nameSchema); assertFalse(namePrefixes.containsKey("tns")); Element serviceSchema=(Element)assertValid("//xsd:schema[@targetNamespace='http://impl.namespaces.aegis.cxf.apache.org']",rootElement).item(0); Map servicePrefixes=getNodeNamespaceDeclarations(serviceSchema); String testPrefix=lookupPrefix(servicePrefixes,URN_AEGIS_NAMESPACE_TEST); assertEquals(AEGIS_TEST_NAMESPACE_PREFIX_XYZZY,testPrefix); serviceAndMapping.getServer().destroy(); }

Class: org.apache.cxf.aegis.namespaces.NamespaceConfusionTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testNameNamespace() throws Exception { org.w3c.dom.Document doc=getWSDLDocument("NameServiceImpl"); Element rootElement=doc.getDocumentElement(); Definition def=getWSDLDefinition("NameServiceImpl"); StringWriter sink=new StringWriter(); WSDLFactory.newInstance().newWSDLWriter().writeWSDL(def,sink); NodeList aonNodes=assertValid("//xsd:complexType[@name='ArrayOfName']/xsd:sequence/xsd:element",doc); Element arrayOfNameElement=(Element)aonNodes.item(0); String typename=arrayOfNameElement.getAttribute("type"); String prefix=typename.split(":")[0]; String uri=getNamespaceForPrefix(rootElement,arrayOfNameElement,prefix); assertNotNull(uri); AegisType nameType=tm.getTypeCreator().createType(Name.class); QName tmQname=nameType.getSchemaType(); assertEquals(tmQname.getNamespaceURI(),uri); }

Class: org.apache.cxf.aegis.override.OverrideTypeTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testOverrideBean() throws Exception { AegisDatabinding aegisDatabinding=new AegisDatabinding(); Set types=new HashSet(); types.add("org.apache.cxf.aegis.inheritance.Employee"); aegisDatabinding.setOverrideTypes(types); DataReader dataReader=aegisDatabinding.createReader(XMLStreamReader.class); InputStream employeeBytes=testUtilities.getResourceAsStream("/org/apache/cxf/aegis/override/employee.xml"); XMLInputFactory readerFactory=XMLInputFactory.newInstance(); XMLStreamReader reader=readerFactory.createXMLStreamReader(employeeBytes); Object objectRead=dataReader.read(reader); assertNotNull(objectRead); assertTrue(objectRead instanceof Employee); Employee e=(Employee)objectRead; assertEquals("long",e.getDivision()); }

Class: org.apache.cxf.aegis.standalone.StandaloneReadTest

InternalCallVerifier EqualityVerifier 
@Test public void testCollectionReadXsiType() throws Exception { context=new AegisContext(); Set roots=new HashSet(); java.lang.reflect.Type listStringType=ListStringInterface.class.getMethods()[0].getGenericReturnType(); roots.add(listStringType); context.setRootClasses(roots); context.initialize(); XMLStreamReader streamReader=testUtilities.getResourceAsXMLStreamReader("topLevelListWithXsiType.xml"); AegisReader reader=context.createXMLStreamReader(); Object something=reader.read(streamReader); List correctAnswer=new ArrayList(); correctAnswer.add("cat"); correctAnswer.add("dog"); correctAnswer.add("hailstorm"); assertEquals(correctAnswer,something); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testCollectionReadNoXsiType() throws Exception { context=new AegisContext(); Set roots=new HashSet(); java.lang.reflect.Type listStringType=ListStringInterface.class.getMethods()[0].getGenericReturnType(); roots.add(listStringType); context.setRootClasses(roots); context.initialize(); XMLStreamReader streamReader=testUtilities.getResourceAsXMLStreamReader("topLevelList.xml"); AegisReader reader=context.createXMLStreamReader(); QName magicTypeQName=new QName("urn:org.apache.cxf.aegis.types","ArrayOfString"); AegisType aegisRegisteredType=context.getTypeMapping().getType(magicTypeQName); Object something=reader.read(streamReader,aegisRegisteredType); List correctAnswer=new ArrayList(); correctAnswer.add("cat"); correctAnswer.add("dog"); correctAnswer.add("hailstorm"); assertEquals(correctAnswer,something); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testSimpleBeanRead() throws Exception { context=new AegisContext(); Set rootClasses=new HashSet(); rootClasses.add(SimpleBean.class); context.setRootClasses(rootClasses); context.initialize(); XMLStreamReader streamReader=testUtilities.getResourceAsXMLStreamReader("simpleBean1.xml"); AegisReader reader=context.createXMLStreamReader(); Object something=reader.read(streamReader); assertTrue(something instanceof SimpleBean); SimpleBean simpleBean=(SimpleBean)something; assertEquals("howdy",simpleBean.getHowdy()); }

Class: org.apache.cxf.aegis.standalone.StandaloneWriteTest

APIUtilityVerifier EqualityVerifier 
@Test public void testWriteCollection() throws Exception { context=new AegisContext(); context.setWriteXsiTypes(true); context.initialize(); List strings=new ArrayList(); strings.add("cat"); strings.add("dog"); strings.add("hailstorm"); AegisWriter writer=context.createXMLStreamWriter(); StringWriter stringWriter=new StringWriter(); XMLStreamWriter xmlWriter=xmlOutputFactory.createXMLStreamWriter(stringWriter); java.lang.reflect.Type listStringType=ListStringInterface.class.getMethods()[0].getGenericReturnType(); writer.write(strings,new QName("urn:borghes","items"),false,xmlWriter,listStringType); xmlWriter.close(); String xml=stringWriter.toString(); XMLStreamReader reader=xmlInputFactory.createXMLStreamReader(new StringReader(xml)); reader.nextTag(); assertEquals("urn:borghes",reader.getNamespaceURI()); assertEquals("items",reader.getLocalName()); reader.nextTag(); assertEquals(reader.getNamespaceURI(),"urn:org.apache.cxf.aegis.types"); assertEquals("string",reader.getLocalName()); String text=reader.getElementText(); assertEquals("cat",text); reader.nextTag(); assertEquals(reader.getNamespaceURI(),"urn:org.apache.cxf.aegis.types"); assertEquals("string",reader.getLocalName()); text=reader.getElementText(); assertEquals("dog",text); reader.nextTag(); assertEquals(reader.getNamespaceURI(),"urn:org.apache.cxf.aegis.types"); assertEquals("string",reader.getLocalName()); text=reader.getElementText(); assertEquals("hailstorm",text); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testTypeLookup() throws Exception { context=new AegisContext(); context.initialize(); AegisType st=context.getTypeMapping().getType(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI,"string")); assertNotNull(st); assertEquals(st.getClass(),StringType.class); }

APIUtilityVerifier EqualityVerifier 
@Test public void testBasicTypeWrite() throws Exception { context=new AegisContext(); context.initialize(); AegisWriter writer=context.createXMLStreamWriter(); StringWriter stringWriter=new StringWriter(); XMLStreamWriter xmlWriter=xmlOutputFactory.createXMLStreamWriter(stringWriter); writer.write("ball-of-yarn",new QName("urn:meow","cat-toy"),false,xmlWriter,new StringType()); xmlWriter.close(); String xml=stringWriter.toString(); XMLStreamReader reader=xmlInputFactory.createXMLStreamReader(new StringReader(xml)); reader.nextTag(); assertEquals("urn:meow",reader.getNamespaceURI()); assertEquals("cat-toy",reader.getLocalName()); reader.next(); String text=reader.getText(); assertEquals("ball-of-yarn",text); }

Class: org.apache.cxf.aegis.type.array.FlatArrayTest

InternalCallVerifier EqualityVerifier 
@Test public void testFlatCollection() throws Exception { ClientProxyFactoryBean proxyFac=new ClientProxyFactoryBean(); proxyFac.setDataBinding(new AegisDatabinding()); proxyFac.setAddress("local://FlatArray"); proxyFac.setBus(getBus()); FlatArrayServiceInterface client=proxyFac.create(FlatArrayServiceInterface.class); BeanWithFlatCollection bwfc=new BeanWithFlatCollection(); bwfc.getValues().add(1); bwfc.getValues().add(2); bwfc.getValues().add(3); bwfc=client.echoBeanWithFlatCollection(bwfc); assertEquals(3,bwfc.getValues().size()); assertEquals(Integer.valueOf(1),bwfc.getValues().get(0)); assertEquals(Integer.valueOf(2),bwfc.getValues().get(1)); assertEquals(Integer.valueOf(3),bwfc.getValues().get(2)); }

EqualityVerifier 
@Test public void testDataMovementPart() throws Exception { ClientProxyFactoryBean proxyFac=new ClientProxyFactoryBean(); proxyFac.setDataBinding(new AegisDatabinding()); proxyFac.setAddress("local://FlatArray"); proxyFac.setBus(getBus()); FlatArrayServiceInterface client=proxyFac.create(FlatArrayServiceInterface.class); client.submitStringArray(STRING_ARRAY); assertArrayEquals(STRING_ARRAY,service.stringArrayValue); }

EqualityVerifier 
@Test public void testDataMovementBean() throws Exception { ClientProxyFactoryBean proxyFac=new ClientProxyFactoryBean(); proxyFac.setDataBinding(new AegisDatabinding()); proxyFac.setAddress("local://FlatArray"); proxyFac.setBus(getBus()); FlatArrayServiceInterface client=proxyFac.create(FlatArrayServiceInterface.class); BeanWithFlatArray bwfa=new BeanWithFlatArray(); bwfa.setValues(INT_ARRAY); client.takeBeanWithFlatArray(bwfa); assertArrayEquals(INT_ARRAY,service.beanWithFlatArrayValue.getValues()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testXmlConfigurationOfParameterTypeSchema() throws Exception { NodeList typeList=assertValid("/wsdl:definitions/wsdl:types" + "/xsd:schema" + "[@targetNamespace='http://array.type.aegis.cxf.apache.org/']"+ "/xsd:complexType[@name=\"submitStringArray\"]"+ "/xsd:sequence/xsd:element"+ "[@name='array']",arrayWsdlDoc); Element typeElement=(Element)typeList.item(0); String nillableValue=typeElement.getAttribute("nillable"); assertTrue(nillableValue == null || "".equals(nillableValue) || "false".equals("nillableValue")); String typeString=typeElement.getAttribute("type"); assertEquals("xsd:string",typeString); typeList=assertValid("/wsdl:definitions/wsdl:types" + "/xsd:schema[@targetNamespace='http://array.type.aegis.cxf.apache.org']" + "/xsd:complexType[@name='BeanWithFlatArray']"+ "/xsd:sequence/xsd:element[@name='values']",arrayWsdlDoc); typeElement=(Element)typeList.item(0); assertValidBoolean("@type='xsd:int'",typeElement); }

Class: org.apache.cxf.aegis.type.basic.BeanTest

InternalCallVerifier EqualityVerifier 
@Test public void testBean() throws Exception { defaultContext(); BeanType type=new BeanType(); type.setTypeClass(SimpleBean.class); type.setTypeMapping(mapping); type.setSchemaType(new QName("urn:Bean","bean")); ElementReader reader=new ElementReader(getResourceAsStream("bean1.xml")); SimpleBean bean=(SimpleBean)type.readObject(reader,getContext()); assertEquals("bleh",bean.getBleh()); assertEquals("howdy",bean.getHowdy()); reader.getXMLStreamReader().close(); reader=new ElementReader(getResourceAsStream("bean2.xml")); bean=(SimpleBean)type.readObject(reader,getContext()); assertEquals("bleh",bean.getBleh()); assertEquals("howdy",bean.getHowdy()); reader.getXMLStreamReader().close(); reader=new ElementReader(getResourceAsStream("bean7.xml")); bean=(SimpleBean)type.readObject(reader,getContext()); assertEquals("",bean.getBleh()); assertEquals("howdy",bean.getHowdy()); reader.getXMLStreamReader().close(); bean.setBleh("bleh"); Element element=writeObjectToElement(type,bean,getContext()); assertValid("/b:root/b:bleh[text()='bleh']",element); assertValid("/b:root/b:howdy[text()='howdy']",element); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testUnmappedProperty() throws Exception { defaultContext(); String ns="urn:Bean"; BeanTypeInfo info=new BeanTypeInfo(SimpleBean.class,ns,false); QName name=new QName(ns,"howdycustom"); info.mapElement("howdy",name); info.setTypeMapping(mapping); assertEquals("howdy",info.getPropertyDescriptorFromMappedName(name).getName()); BeanType type=new BeanType(info); type.setTypeClass(SimpleBean.class); type.setTypeMapping(mapping); type.setSchemaType(new QName("urn:Bean","bean")); ElementReader reader=new ElementReader(getResourceAsStream("bean3.xml")); SimpleBean bean=(SimpleBean)type.readObject(reader,getContext()); assertEquals("howdy",bean.getHowdy()); assertNull(bean.getBleh()); reader.getXMLStreamReader().close(); Element element=writeObjectToElement(type,bean,getContext()); assertInvalid("/b:root/b:bleh",element); assertValid("/b:root/b:howdycustom[text()='howdy']",element); }

InternalCallVerifier EqualityVerifier 
@Test public void testExtendedBean() throws Exception { defaultContext(); BeanTypeInfo info=new BeanTypeInfo(ExtendedBean.class,"urn:Bean"); info.setTypeMapping(mapping); BeanType type=new BeanType(info); type.setTypeClass(ExtendedBean.class); type.setTypeMapping(mapping); type.setSchemaType(new QName("urn:Bean","bean")); PropertyDescriptor[] pds=info.getPropertyDescriptors(); assertEquals(9,pds.length); ExtendedBean bean=new ExtendedBean(); bean.setHowdy("howdy"); Element element=writeObjectToElement(type,bean,getContext()); assertValid("/b:root/b:howdy[text()='howdy']",element); }

InternalCallVerifier EqualityVerifier 
@Test public void testBeanWithXsiType() throws Exception { defaultContext(); BeanType type=new BeanType(); type.setTypeClass(SimpleBean.class); type.setTypeMapping(mapping); type.setSchemaType(new QName("urn:Bean","bean")); ElementReader reader=new ElementReader(getResourceAsStream("bean9.xml")); Context ctx=getContext(); ctx.getGlobalContext().setReadXsiTypes(false); SimpleBean bean=(SimpleBean)type.readObject(reader,ctx); assertEquals("bleh",bean.getBleh()); assertEquals("howdy",bean.getHowdy()); reader.getXMLStreamReader().close(); Element element=writeObjectToElement(type,bean,getContext()); assertValid("/b:root/b:bleh[text()='bleh']",element); assertValid("/b:root/b:howdy[text()='howdy']",element); }

APIUtilityVerifier IterativeVerifier BranchVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCharMappings() throws Exception { defaultContext(); BeanType type=(BeanType)mapping.getTypeCreator().createType(SimpleBean.class); type.setTypeClass(SimpleBean.class); type.setTypeMapping(mapping); XmlSchema schema=newXmlSchema("urn:Bean"); type.writeSchema(schema); XmlSchemaComplexType btype=(XmlSchemaComplexType)schema.getTypeByName("SimpleBean"); XmlSchemaSequence seq=(XmlSchemaSequence)btype.getParticle(); boolean charok=false; for (int x=0; x < seq.getItems().size(); x++) { XmlSchemaSequenceMember o=seq.getItems().get(x); if (o instanceof XmlSchemaElement) { XmlSchemaElement oe=(XmlSchemaElement)o; if ("character".equals(oe.getName())) { charok=true; assertNotNull(oe.getSchemaTypeName()); assertTrue(oe.isNillable()); assertEquals(CharacterAsStringType.CHARACTER_AS_STRING_TYPE_QNAME,oe.getSchemaTypeName()); } } } assertTrue(charok); }

APIUtilityVerifier IterativeVerifier BranchVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testNillableAnnotation() throws Exception { context=new AegisContext(); TypeCreationOptions config=new TypeCreationOptions(); config.setDefaultNillable(false); config.setDefaultMinOccurs(1); context.setTypeCreationOptions(config); context.initialize(); mapping=context.getTypeMapping(); BeanType type=(BeanType)mapping.getTypeCreator().createType(BeanWithNillableItem.class); type.setTypeClass(BeanWithNillableItem.class); type.setTypeMapping(mapping); XmlSchema schema=newXmlSchema("urn:Bean"); type.writeSchema(schema); XmlSchemaComplexType btype=(XmlSchemaComplexType)schema.getTypeByName("BeanWithNillableItem"); XmlSchemaSequence seq=(XmlSchemaSequence)btype.getParticle(); boolean itemFound=false; boolean itemNotNillableFound=false; for (int x=0; x < seq.getItems().size(); x++) { XmlSchemaSequenceMember o=seq.getItems().get(x); if (o instanceof XmlSchemaElement) { XmlSchemaElement oe=(XmlSchemaElement)o; if ("item".equals(oe.getName())) { itemFound=true; assertTrue(oe.isNillable()); assertEquals(0,oe.getMinOccurs()); } else if ("itemNotNillable".equals(oe.getName())) { itemNotNillableFound=true; assertFalse(oe.isNillable()); } } } assertTrue(itemFound); assertTrue(itemNotNillableFound); }

InternalCallVerifier EqualityVerifier 
@Test public void testAttributeMapDifferentNS() throws Exception { defaultContext(); BeanTypeInfo info=new BeanTypeInfo(SimpleBean.class,"urn:Bean"); info.mapAttribute("howdy",new QName("urn:Bean2","howdy")); info.mapAttribute("bleh",new QName("urn:Bean2","bleh")); info.setTypeMapping(mapping); BeanType type=new BeanType(info); type.setTypeClass(SimpleBean.class); type.setTypeMapping(mapping); type.setSchemaType(new QName("urn:Bean","bean")); ElementReader reader=new ElementReader(getResourceAsStream("bean8.xml")); SimpleBean bean=(SimpleBean)type.readObject(reader,getContext()); assertEquals("bleh",bean.getBleh()); assertEquals("howdy",bean.getHowdy()); reader.getXMLStreamReader().close(); ByteArrayOutputStream bos=new ByteArrayOutputStream(); ElementWriter writer=new ElementWriter(bos,"root","urn:Bean"); type.writeObject(bean,writer,getContext()); writer.close(); writer.flush(); bos.close(); Document doc=StaxUtils.read(new ByteArrayInputStream(bos.toByteArray())); Element element=doc.getDocumentElement(); addNamespace("b2","urn:Bean2"); assertValid("/b:root[@b2:bleh='bleh']",element); assertValid("/b:root[@b2:howdy='howdy']",element); }

APIUtilityVerifier IterativeVerifier BranchVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testByteMappings() throws Exception { defaultContext(); BeanType type=(BeanType)mapping.getTypeCreator().createType(SimpleBean.class); type.setTypeClass(SimpleBean.class); type.setTypeMapping(mapping); XmlSchema schema=newXmlSchema("urn:Bean"); type.writeSchema(schema); XmlSchemaComplexType btype=(XmlSchemaComplexType)schema.getTypeByName("SimpleBean"); XmlSchemaSequence seq=(XmlSchemaSequence)btype.getParticle(); boolean littleByteOk=false; boolean bigByteOk=false; for (int x=0; x < seq.getItems().size(); x++) { XmlSchemaSequenceMember o=seq.getItems().get(x); if (o instanceof XmlSchemaElement) { XmlSchemaElement oe=(XmlSchemaElement)o; if ("littleByte".equals(oe.getName())) { littleByteOk=true; assertNotNull(oe.getSchemaTypeName()); assertEquals(Constants.XSD_BYTE,oe.getSchemaTypeName()); } else if ("bigByte".equals(oe.getName())) { bigByteOk=true; assertNotNull(oe.getSchemaTypeName()); assertEquals(Constants.XSD_BYTE,oe.getSchemaTypeName()); } } } assertTrue(littleByteOk); assertTrue(bigByteOk); SimpleBean bean=new SimpleBean(); bean.setBigByte(new Byte((byte)0xfe)); bean.setLittleByte((byte)0xfd); Element element=writeObjectToElement(type,bean,getContext()); Byte bb=new Byte((byte)0xfe); String bbs=bb.toString(); assertValid("/b:root/bz:bigByte[text()='" + bbs + "']",element); ElementReader reader=new ElementReader(getResourceAsStream("byteBeans.xml")); bean=(SimpleBean)type.readObject(reader,getContext()); assertEquals(-5,bean.getLittleByte()); assertEquals(25,bean.getBigByte().byteValue()); reader.getXMLStreamReader().close(); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testInterfaceBeans() throws Exception { defaultContext(); BeanType type=new BeanType(); type.setTypeClass(SerializableBean.class); type.setTypeMapping(mapping); type.setSchemaType(new QName("urn:foo","SerializableBean")); AegisType stringType=mapping.getType(String.class); assertTrue(type.getDependencies().contains(stringType)); type=new BeanType(); type.setTypeClass(CloneableBean.class); type.setTypeMapping(mapping); type.setSchemaType(new QName("urn:foo","CloneableBean")); assertEquals(1,type.getDependencies().size()); assertTrue(type.getDependencies().contains(stringType)); type=new BeanType(); type.setTypeClass(SimpleInterface.class); type.setTypeMapping(mapping); type.setSchemaType(new QName("urn:foo","SimpleInterface")); assertEquals(1,type.getDependencies().size()); assertTrue(type.getDependencies().contains(stringType)); type=new BeanType(); type.setTypeClass(ExtendingInterface.class); type.setTypeMapping(mapping); type.setSchemaType(new QName("urn:foo","ExtendingInterface")); Set dependencies=type.getDependencies(); assertEquals(2,dependencies.size()); dependencies.remove(stringType); assertEquals(SimpleInterface.class,dependencies.iterator().next().getTypeClass()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testAttributeMap() throws Exception { defaultContext(); BeanTypeInfo info=new BeanTypeInfo(SimpleBean.class,"urn:Bean"); info.mapAttribute("howdy",new QName("urn:Bean","howdy")); info.mapAttribute("bleh",new QName("urn:Bean","bleh")); info.setTypeMapping(mapping); BeanType type=new BeanType(info); type.setTypeClass(SimpleBean.class); type.setTypeMapping(mapping); type.setSchemaType(new QName("urn:Bean","bean")); ElementReader reader=new ElementReader(getResourceAsStream("bean4.xml")); SimpleBean bean=(SimpleBean)type.readObject(reader,getContext()); assertEquals("bleh",bean.getBleh()); assertEquals("howdy",bean.getHowdy()); reader.getXMLStreamReader().close(); Element element=writeObjectToElement(type,bean,getContext()); assertValid("/b:root[@b:bleh='bleh']",element); assertValid("/b:root[@b:howdy='howdy']",element); XmlSchema schema=newXmlSchema("urn:Bean"); type.writeSchema(schema); XmlSchemaComplexType stype=(XmlSchemaComplexType)schema.getTypeByName("bean"); boolean howdy=false; boolean bleh=false; for (int x=0; x < stype.getAttributes().size(); x++) { XmlSchemaObject o=stype.getAttributes().get(x); if (o instanceof XmlSchemaAttribute) { XmlSchemaAttribute a=(XmlSchemaAttribute)o; if ("howdy".equals(a.getName())) { howdy=true; } if ("bleh".equals(a.getName())) { bleh=true; } } } assertTrue(howdy); assertTrue(bleh); }

APIUtilityVerifier IterativeVerifier BranchVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testNillableInt() throws Exception { defaultContext(); BeanTypeInfo info=new BeanTypeInfo(IntBean.class,"urn:Bean"); info.setTypeMapping(mapping); BeanType type=new BeanType(info); type.setTypeClass(IntBean.class); type.setTypeMapping(mapping); type.setSchemaType(new QName("urn:Bean","bean")); XmlSchema schema=newXmlSchema("urn:Bean"); type.writeSchema(schema); XmlSchemaComplexType btype=(XmlSchemaComplexType)schema.getTypeByName("bean"); XmlSchemaSequence seq=(XmlSchemaSequence)btype.getParticle(); boolean int1ok=false; boolean int2ok=false; for (int x=0; x < seq.getItems().size(); x++) { XmlSchemaSequenceMember o=seq.getItems().get(x); if (o instanceof XmlSchemaElement) { XmlSchemaElement oe=(XmlSchemaElement)o; if ("int1".equals(oe.getName())) { int1ok=true; assertTrue(oe.isNillable()); assertEquals(0,oe.getMinOccurs()); } else if ("int2".equals(oe.getName())) { int2ok=true; assertEquals(0,oe.getMinOccurs()); assertFalse(oe.isNillable()); } } } assertTrue(int1ok); assertTrue(int2ok); }

APIUtilityVerifier IterativeVerifier BranchVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testNillableIntMinOccurs1() throws Exception { context=new AegisContext(); TypeCreationOptions config=new TypeCreationOptions(); config.setDefaultMinOccurs(1); config.setDefaultNillable(false); context.setTypeCreationOptions(config); context.initialize(); mapping=context.getTypeMapping(); BeanType type=(BeanType)mapping.getTypeCreator().createType(IntBean.class); type.setTypeClass(IntBean.class); type.setTypeMapping(mapping); XmlSchema schema=newXmlSchema("urn:Bean"); type.writeSchema(schema); XmlSchemaComplexType btype=(XmlSchemaComplexType)schema.getTypeByName("IntBean"); XmlSchemaSequence seq=(XmlSchemaSequence)btype.getParticle(); boolean int1ok=false; for (int x=0; x < seq.getItems().size(); x++) { XmlSchemaSequenceMember o=seq.getItems().get(x); if (o instanceof XmlSchemaElement) { XmlSchemaElement oe=(XmlSchemaElement)o; if ("int1".equals(oe.getName())) { int1ok=true; assertFalse(oe.isNillable()); assertEquals(1,oe.getMinOccurs()); } } } assertTrue(int1ok); }

Class: org.apache.cxf.aegis.type.basic.DynamicProxyTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDynamicProxyMissingAttribute() throws Exception { BeanType type=new BeanType(); type.setTypeClass(IMyInterface.class); type.setTypeMapping(mapping); type.setSchemaType(new QName("urn:MyInterface","data")); ElementReader reader=new ElementReader(getResourceAsStream("MyInterface.xml")); IMyInterface data=(IMyInterface)type.readObject(reader,getContext()); assertEquals("junk",data.getName()); assertNull(data.getType()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDynamicProxy() throws Exception { BeanType type=new BeanType(); type.setTypeClass(IMyInterface.class); type.setTypeMapping(mapping); type.setSchemaType(new QName("urn:MyInterface","data")); ElementReader reader=new ElementReader(getResourceAsStream("MyInterface.xml")); IMyInterface data=(IMyInterface)type.readObject(reader,getContext()); assertEquals("junk",data.getName()); assertEquals(true,data.isUseless()); data.setName("bigjunk"); data.setUseless(false); assertEquals("bigjunk",data.getName()); assertEquals(false,data.isUseless()); assertTrue(data.hashCode() != 0); assertTrue(data.equals(data)); assertNotNull(data.toString()); assertEquals("foo",data.getFOO()); assertEquals(0,data.getNonSpecifiedInt()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDynamicProxyNested() throws Exception { BeanType type=new BeanType(); type.setTypeClass(IMyInterface.class); type.setSchemaType(new QName("urn:MyInterface","myInterface")); type.setTypeMapping(mapping); BeanType type2=new BeanType(); type2.setTypeClass(IMyInterface2.class); type2.setSchemaType(new QName("urn:MyInterface2","myInterface2")); type2.setTypeMapping(mapping); type2.getTypeInfo().mapType(new QName("urn:MyInterface","myInterface"),type); ElementReader reader=new ElementReader(getResourceAsStream("MyInterface2.xml")); IMyInterface2 data=(IMyInterface2)type2.readObject(reader,getContext()); assertNotNull(data.getMyInterface()); assertEquals("junk",data.getMyInterface().getName()); assertEquals(true,data.getMyInterface().isUseless()); }

Class: org.apache.cxf.aegis.type.encoded.ArrayTypeInfoTest

EqualityVerifier 
@Test public void testArrayTypeInfo() throws Exception { assertEquals(new ArrayTypeInfo(new QName("","addr"),0,4),"addr[4]"); assertEquals(new ArrayTypeInfo(new QName("urn:Bean","addr","b"),0,4),"b:addr[4]"); assertEquals(new ArrayTypeInfo(new QName("urn:Bean","addr","b"),0,4,8,9),"b:addr[4,8,9]"); assertEquals(new ArrayTypeInfo(new QName("urn:Bean","addr","b"),0,4),"b:addr[4]"); assertEquals(new ArrayTypeInfo(new QName("urn:Bean","addr","b"),1,4),"b:addr[][4]"); assertEquals(new ArrayTypeInfo(new QName("urn:Bean","addr","b"),2,4),"b:addr[,][4]"); assertEquals(new ArrayTypeInfo(new QName("urn:Bean","addr","b"),4,4),"b:addr[,,,][4]"); assertEquals(new ArrayTypeInfo(new QName("urn:Bean","addr","b"),4,4,8,9),"b:addr[,,,][4,8,9]"); assertInvalid("x"); assertInvalid("b:addr"); assertInvalid(":addr[4]"); assertInvalid("b:a:ddress[4]"); assertInvalid("b:addr[0]"); assertInvalid("b:addr[a]"); assertInvalid("b:addr[4,0]"); assertInvalid("b:addr[4,a]"); assertInvalid("b:addr[4,0,5]"); assertInvalid("b:addr[4,a,5]"); assertInvalid("b:addr[]"); assertInvalid("b:addr[,]"); assertInvalid("b:addr[,][]"); assertInvalid("b:addr],][4]"); assertInvalid("b:addr[,[[4]"); assertInvalid("b:addr[,]]4]"); assertInvalid("b:addr[,][4["); assertInvalid("b:addr[,][]4]"); assertInvalid("b:addr[,][][4]"); assertInvalid("b:addr[,][][4["); assertInvalid("b:addr[,][][4]end"); }

Class: org.apache.cxf.aegis.type.encoded.SoapArrayTypeTest

InternalCallVerifier EqualityVerifier 
@Test public void testPartiallyTransmitted() throws Exception { Context context=getContext(); ElementReader reader=new ElementReader(getClass().getResourceAsStream("arrayPartiallyTransmitted.xml")); int[] numbers=(int[])createArrayType(int[].class).readObject(reader,context); reader.getXMLStreamReader().close(); assertArrayEquals(new int[]{0,0,3,4,0},numbers); numbers=readWriteReadRef("arrayPartiallyTransmitted.xml",int[].class); assertArrayEquals(new int[]{0,0,3,4,0},numbers); }

EqualityVerifier 
@Test public void testUrTypeArrayReadWriteRef2() throws Exception { Object[] objects; objects=readWriteReadRef("arrayUrType2.xml",Object[].class); assertArrayEquals(new Object[]{42,new BigDecimal("42.42"),"Forty Two"},objects); }

InternalCallVerifier EqualityVerifier 
@Test public void testSimpleArray() throws Exception { Context context=getContext(); ElementReader reader=new ElementReader(getClass().getResourceAsStream("arraySimple.xml")); int[] numbers=(int[])createArrayType(int[].class).readObject(reader,context); reader.getXMLStreamReader().close(); assertArrayEquals(new int[]{3,4},numbers); numbers=readWriteReadRef("arraySimple.xml",int[].class); assertArrayEquals(new int[]{3,4},numbers); }

EqualityVerifier 
@Test public void testUrTypeArrayReadWriteRef1() throws Exception { Object[] objects; objects=readWriteReadRef("arrayUrType1.xml",Object[].class); assertArrayEquals(new Object[]{42,new Float(42.42f),"Forty Two"},objects); }

InternalCallVerifier EqualityVerifier 
@Test public void testAnyTypeArray() throws Exception { Context context=getContext(); ElementReader reader=new ElementReader(getClass().getResourceAsStream("arrayAnyType1.xml")); Object[] objects=(Object[])createArrayType(Object[].class).readObject(reader,context); reader.getXMLStreamReader().close(); assertArrayEquals(new Object[]{42,(float)42.42,"Forty Two"},objects); reader=new ElementReader(getClass().getResourceAsStream("arrayAnyType2.xml")); objects=(Object[])createArrayType(Object[].class).readObject(reader,context); reader.getXMLStreamReader().close(); assertArrayEquals(new Object[]{42,new BigDecimal("42.42"),"Forty Two"},objects); objects=readWriteReadRef("arrayAnyType1.xml",Object[].class); assertArrayEquals(new Object[]{42,(float)42.42,"Forty Two"},objects); objects=readWriteReadRef("arrayAnyType2.xml",Object[].class); assertArrayEquals(new Object[]{42,new BigDecimal("42.42"),"Forty Two"},objects); }

InternalCallVerifier EqualityVerifier 
@Test public void testSquareArray() throws Exception { Context context=getContext(); ElementReader reader=new ElementReader(getClass().getResourceAsStream("arraySquare.xml")); String[][][] strings=(String[][][])createArrayType(String[][][].class).readObject(reader,context); reader.getXMLStreamReader().close(); assertArrayEquals(ARRAY_2_3_4,strings); strings=readWriteReadRef("arraySquare.xml",String[][][].class); assertArrayEquals(ARRAY_2_3_4,strings); }

InternalCallVerifier EqualityVerifier 
@Test public void testArrayOfArrays() throws Exception { Context context=getContext(); ElementReader reader=new ElementReader(getClass().getResourceAsStream("arrayArrayOfArrays1.xml")); String[][][] strings=(String[][][])createArrayType(String[][][].class).readObject(reader,context); reader.getXMLStreamReader().close(); assertArrayEquals(ARRAY_2_3_4,strings); strings=readWriteReadRef("arrayArrayOfArrays1.xml",String[][][].class); assertArrayEquals(ARRAY_2_3_4,strings); }

InternalCallVerifier EqualityVerifier 
@Test public void testUrTypeArray() throws Exception { Context context=getContext(); ElementReader reader=new ElementReader(getClass().getResourceAsStream("arrayUrType1.xml")); Object[] objects=(Object[])createArrayType(Object[].class).readObject(reader,context); reader.getXMLStreamReader().close(); assertArrayEquals(new Object[]{42,(float)42.42,"Forty Two"},objects); reader=new ElementReader(getClass().getResourceAsStream("arrayUrType2.xml")); objects=(Object[])createArrayType(Object[].class).readObject(reader,context); reader.getXMLStreamReader().close(); assertArrayEquals(Arrays.asList(objects).toString(),new Object[]{42,new BigDecimal("42.42"),"Forty Two"},objects); }

Class: org.apache.cxf.aegis.type.java5.AnnotatedTypeTest

APIUtilityVerifier BranchVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testNillableAndMinOccurs(){ BeanType type=(BeanType)tm.getTypeCreator().createType(AnnotatedBean4.class); AnnotatedTypeInfo info=(AnnotatedTypeInfo)type.getTypeInfo(); Iterator elements=info.getElements().iterator(); assertTrue(elements.hasNext()); QName element=elements.next(); if ("minOccursProperty".equals(element.getLocalPart())) { assertEquals(1,info.getMinOccurs(element)); } else { assertFalse(info.isNillable(element)); } assertTrue(elements.hasNext()); element=elements.next(); if ("minOccursProperty".equals(element.getLocalPart())) { assertEquals(1,info.getMinOccurs(element)); } else { assertFalse(info.isNillable(element)); } }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
/** * Test if attributeProperty is correctly mapped to attProp by * applying the xml mapping file .aegis.xml */ @Test public void testAegisType(){ BeanType type=(BeanType)tm.getTypeCreator().createType(AnnotatedBean3.class); assertEquals(0,type.getTypeInfo().getAttributes().size()); Iterator itr=type.getTypeInfo().getElements().iterator(); assertTrue(itr.hasNext()); QName q=itr.next(); assertEquals("attProp",q.getLocalPart()); }

Class: org.apache.cxf.aegis.type.java5.CollectionTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testObjectDTO(){ tm=new DefaultTypeMapping(Constants.URI_2001_SCHEMA_XSD); creator=new Java5TypeCreator(); creator.setConfiguration(new TypeCreationOptions()); tm.setTypeCreator(creator); AegisType dto=creator.createType(ObjectDTO.class); Set deps=dto.getDependencies(); assertFalse(deps.isEmpty()); AegisType type=deps.iterator().next(); assertTrue(type instanceof CollectionType); CollectionType colType=(CollectionType)type; deps=dto.getDependencies(); assertEquals(1,deps.size()); AegisType comType=colType.getComponentType(); assertEquals(Object.class,comType.getTypeClass()); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testRecursiveCollections() throws Exception { Method m=CollectionService.class.getMethod("getStringCollections",new Class[0]); AegisType type=creator.createType(m,-1); tm.register(type); assertTrue(type instanceof CollectionType); CollectionType colType=(CollectionType)type; QName componentName=colType.getSchemaType(); assertEquals("ArrayOfArrayOfString",componentName.getLocalPart()); type=colType.getComponentType(); assertNotNull(type); assertTrue(type instanceof CollectionType); CollectionType colType2=(CollectionType)type; componentName=colType2.getSchemaType(); assertEquals("ArrayOfString",componentName.getLocalPart()); type=colType2.getComponentType(); assertTrue(type.getTypeClass().isAssignableFrom(String.class)); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testType() throws Exception { Method m=CollectionService.class.getMethod("getStrings",new Class[0]); AegisType type=creator.createType(m,-1); tm.register(type); assertTrue(type instanceof CollectionType); CollectionType colType=(CollectionType)type; QName componentName=colType.getSchemaType(); assertEquals("ArrayOfString",componentName.getLocalPart()); assertEquals("ArrayOfString",componentName.getLocalPart()); type=colType.getComponentType(); assertNotNull(type); assertTrue(type.getTypeClass().isAssignableFrom(String.class)); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testCollectionDTO(){ tm=new DefaultTypeMapping(Constants.URI_2001_SCHEMA_XSD); creator=new Java5TypeCreator(); creator.setConfiguration(new TypeCreationOptions()); tm.setTypeCreator(creator); AegisType dto=creator.createType(CollectionDTO.class); Set deps=dto.getDependencies(); AegisType type=deps.iterator().next(); assertTrue(type instanceof CollectionType); CollectionType colType=(CollectionType)type; deps=dto.getDependencies(); assertEquals(1,deps.size()); AegisType comType=colType.getComponentType(); assertEquals(String.class,comType.getTypeClass()); }

Class: org.apache.cxf.aegis.type.java5.CollectionTestsWithService

InternalCallVerifier EqualityVerifier 
@Test public void returnValueIsCollectionOfArraysOfAny(){ Collection r=csi.returnCollectionOfDOMFragments(); assertEquals(2,r.size()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void returnValueIsCollectionOfArrays(){ Collection doubleDouble=csi.returnCollectionOfPrimitiveArrays(); assertEquals(2,doubleDouble.size()); double[][] data=new double[2][]; for ( double[] array : doubleDouble) { if (array.length == 3) { data[0]=array; } else { data[1]=array; } } assertNotNull(data[0]); assertNotNull(data[1]); assertEquals(3.14,data[0][0],.0001); assertEquals(2,data[0][1],.0001); assertEquals(-666.6,data[0][2],.0001); assertEquals(-666.6,data[1][0],.0001); assertEquals(3.14,data[1][1],.0001); assertEquals(2.0,data[1][2],.0001); }

InternalCallVerifier EqualityVerifier 
@Test public void testListTypes() throws Exception { SortedSet strings=new TreeSet(); strings.add("Able"); strings.add("Baker"); String first=csi.takeSortedStrings(strings); assertEquals("Able",first); HashSet hashedSet=new HashSet(); hashedSet.addAll(strings); String countString=csi.takeUnsortedSet(hashedSet); assertEquals("2",countString); }

Class: org.apache.cxf.aegis.type.java5.ConfigurationTest

InternalCallVerifier EqualityVerifier 
@Test public void testMinOccursDefault0() throws Exception { config.setDefaultMinOccurs(0); AegisType type=tm.getTypeCreator().createType(AnnotatedBean1.class); BeanTypeInfo info=((BeanType)type).getTypeInfo(); assertEquals(info.getMinOccurs(new QName(info.getDefaultNamespace(),"bogusProperty")),0); }

InternalCallVerifier EqualityVerifier 
@Test public void testMinOccursDefault1() throws Exception { config.setDefaultMinOccurs(1); AegisType type=tm.getTypeCreator().createType(AnnotatedBean1.class); BeanTypeInfo info=((BeanType)type).getTypeInfo(); assertEquals(info.getMinOccurs(new QName(info.getDefaultNamespace(),"bogusProperty")),1); }

Class: org.apache.cxf.aegis.type.java5.EnumTypeTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testType() throws Exception { EnumType type=new EnumType(); type.setTypeClass(SmallEnum.class); type.setSchemaType(new QName("urn:test","test")); tm.register(type); Element element=writeObjectToElement(type,SmallEnum.VALUE1,getContext()); assertEquals("VALUE1",element.getTextContent()); XMLStreamReader xreader=StaxUtils.createXMLStreamReader(element); ElementReader reader=new ElementReader(xreader); Object value=type.readObject(reader,getContext()); assertEquals(SmallEnum.VALUE1,value); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testXFireTypeAttributeOnEnum() throws Exception { AegisType type=tm.getTypeCreator().createType(XFireTestEnum.class); assertEquals("urn:xfire:foo",type.getSchemaType().getNamespaceURI()); assertTrue(type instanceof EnumType); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testTypeAttributeOnEnum() throws Exception { AegisType type=tm.getTypeCreator().createType(TestEnum.class); assertEquals("urn:xfire:foo",type.getSchemaType().getNamespaceURI()); assertTrue(type instanceof EnumType); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testJaxbTypeAttributeOnEnum() throws Exception { AegisType type=tm.getTypeCreator().createType(JaxbTestEnum.class); assertEquals("urn:xfire:foo",type.getSchemaType().getNamespaceURI()); assertTrue(type instanceof EnumType); }

Class: org.apache.cxf.aegis.type.java5.JaxbTypeTest

APIUtilityVerifier BranchVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testNillableAndMinOccurs(){ BeanType type=(BeanType)tm.getTypeCreator().createType(JaxbBean4.class); AnnotatedTypeInfo info=(AnnotatedTypeInfo)type.getTypeInfo(); Iterator elements=info.getElements().iterator(); assertTrue(elements.hasNext()); QName element=elements.next(); if ("minOccursProperty".equals(element.getLocalPart())) { assertEquals(1,info.getMinOccurs(element)); } else { assertFalse(info.isNillable(element)); } assertTrue(elements.hasNext()); element=elements.next(); if ("minOccursProperty".equals(element.getLocalPart())) { assertEquals(1,info.getMinOccurs(element)); } else { assertFalse(info.isNillable(element)); } }

InternalCallVerifier EqualityVerifier 
@Test public void testGetSetRequired() throws Exception { BeanType type=new BeanType(new AnnotatedTypeInfo(tm,BadBean.class,"urn:foo",new TypeCreationOptions())); type.setSchemaType(new QName("urn:foo","BadBean")); assertEquals(0,type.getTypeInfo().getElements().size()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
/** * Test if attributeProperty is correctly mapped to attProp by * applying the xml mapping file .aegis.xml */ @Test public void testAegisType(){ BeanType type=(BeanType)tm.getTypeCreator().createType(JaxbBean3.class); assertEquals(0,type.getTypeInfo().getAttributes().size()); Iterator itr=type.getTypeInfo().getElements().iterator(); assertTrue(itr.hasNext()); QName q=itr.next(); assertEquals("attProp",q.getLocalPart()); }

Class: org.apache.cxf.aegis.type.java5.MapTest

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testRecursiveType() throws Exception { Method m=MapService.class.getMethod("getMapOfCollections",new Class[0]); AegisType type=creator.createType(m,-1); tm.register(type); assertTrue(type instanceof MapType); MapType mapType=(MapType)type; QName keyName=mapType.getKeyName(); assertNotNull(keyName); type=mapType.getKeyType(); assertNotNull(type); assertTrue(type instanceof CollectionType); assertEquals(String.class,((CollectionType)type).getComponentType().getTypeClass()); type=mapType.getValueType(); assertNotNull(type); assertTrue(type instanceof CollectionType); assertEquals(Double.class,((CollectionType)type).getComponentType().getTypeClass()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testMapDTO(){ tm=new DefaultTypeMapping(); creator=new Java5TypeCreator(); creator.setConfiguration(new TypeCreationOptions()); tm.setTypeCreator(creator); AegisType dto=creator.createType(MapDTO.class); Set deps=dto.getDependencies(); AegisType type=deps.iterator().next(); assertTrue(type instanceof MapType); MapType mapType=(MapType)type; deps=dto.getDependencies(); assertEquals(1,deps.size()); type=mapType.getKeyType(); assertNotNull(type); assertTrue(type.getTypeClass().isAssignableFrom(String.class)); type=mapType.getValueType(); assertNotNull(type); assertTrue(type.getTypeClass().isAssignableFrom(Integer.class)); }

Class: org.apache.cxf.aegis.type.java5.XFireTypeTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
/** * Test if attributeProperty is correctly mapped to attProp by * applying the xml mapping file .aegis.xml */ @Test public void testAegisType(){ BeanType type=(BeanType)tm.getTypeCreator().createType(XFireBean3.class); assertEquals(0,type.getTypeInfo().getAttributes().size()); Iterator itr=type.getTypeInfo().getElements().iterator(); assertTrue(itr.hasNext()); QName q=itr.next(); assertEquals("attProp",q.getLocalPart()); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetSetRequired() throws Exception { BeanType type=new BeanType(new AnnotatedTypeInfo(tm,BadBean.class,"urn:foo",new TypeCreationOptions())); type.setSchemaType(new QName("urn:foo","BadBean")); assertEquals(0,type.getTypeInfo().getElements().size()); }

APIUtilityVerifier BranchVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testNillableAndMinOccurs(){ BeanType type=(BeanType)tm.getTypeCreator().createType(XFireBean4.class); AnnotatedTypeInfo info=(AnnotatedTypeInfo)type.getTypeInfo(); Iterator elements=info.getElements().iterator(); assertTrue(elements.hasNext()); QName element=elements.next(); if ("minOccursProperty".equals(element.getLocalPart())) { assertEquals(1,info.getMinOccurs(element)); } else { assertFalse(info.isNillable(element)); } assertTrue(elements.hasNext()); element=elements.next(); if ("minOccursProperty".equals(element.getLocalPart())) { assertEquals(1,info.getMinOccurs(element)); } else { assertFalse(info.isNillable(element)); } }

Class: org.apache.cxf.aegis.type.java5.XFireXmlParamTypeTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testType() throws Exception { Method m=CustomTypeService.class.getMethod("doFoo",new Class[]{String.class}); AegisType type=creator.createType(m,0); tm.register(type); assertTrue(type instanceof CustomStringType); assertEquals(new QName("urn:xfire:foo","custom"),type.getSchemaType()); type=creator.createType(m,-1); tm.register(type); assertTrue(type instanceof CustomStringType); assertEquals(new QName("urn:xfire:foo","custom"),type.getSchemaType()); }

Class: org.apache.cxf.aegis.type.java5.XmlParamTypeTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testType() throws Exception { Method m=CustomTypeService.class.getMethod("doFoo",new Class[]{String.class}); AegisType type=creator.createType(m,0); tm.register(type); assertTrue(type instanceof CustomStringType); type=creator.createType(m,-1); tm.register(type); assertTrue(type instanceof CustomStringType); assertEquals(new QName("urn:xfire:foo","custom"),type.getSchemaType()); }

Class: org.apache.cxf.aegis.type.java5.map.StudentTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testReturnMapDocLiteral() throws Exception { JaxWsServerFactoryBean sf=new JaxWsServerFactoryBean(); sf.setServiceClass(StudentServiceDocLiteral.class); sf.setServiceBean(new StudentServiceDocLiteralImpl()); sf.setAddress("local://StudentServiceDocLiteral"); setupAegis(sf); Server server=sf.create(); server.getEndpoint().getInInterceptors().add(new LoggingInInterceptor()); server.getEndpoint().getOutInterceptors().add(new LoggingOutInterceptor()); server.start(); JaxWsProxyFactoryBean proxyFac=new JaxWsProxyFactoryBean(); proxyFac.setAddress("local://StudentServiceDocLiteral"); proxyFac.setBus(getBus()); setupAegis(proxyFac.getClientFactoryBean()); proxyFac.getInInterceptors().add(new LoggingInInterceptor()); proxyFac.getOutInterceptors().add(new LoggingOutInterceptor()); StudentServiceDocLiteral clientInterface=proxyFac.create(StudentServiceDocLiteral.class); Map fullMap=clientInterface.getStudentsMap(); assertNotNull(fullMap); Student one=fullMap.get(Long.valueOf(1)); assertNotNull(one); assertEquals("Student1",one.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testReturnMap() throws Exception { JaxWsServerFactoryBean sf=new JaxWsServerFactoryBean(); sf.setServiceClass(StudentService.class); sf.setServiceBean(new StudentServiceImpl()); sf.setAddress("local://StudentService"); setupAegis(sf); Server server=sf.create(); server.start(); JaxWsProxyFactoryBean proxyFac=new JaxWsProxyFactoryBean(); proxyFac.setAddress("local://StudentService"); proxyFac.setBus(getBus()); setupAegis(proxyFac.getClientFactoryBean()); StudentService clientInterface=proxyFac.create(StudentService.class); Map fullMap=clientInterface.getStudentsMap(); assertNotNull(fullMap); Student one=fullMap.get(Long.valueOf(1)); assertNotNull(one); assertEquals("Student1",one.getName()); Map wildMap=clientInterface.getWildcardMap(); assertEquals("valuestring",wildMap.get("keystring")); }

Class: org.apache.cxf.aegis.type.map.MapsTest

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testObjectsWithMaps() throws Exception { ObjectWithAMap obj1=clientInterface.returnObjectWithAMap(); ObjectWithAMapNs2 obj2=clientInterface.returnObjectWithAMapNs2(); assertNotNull(obj1); assertNotNull(obj2); assertNotNull(obj1.getTheMap()); assertNotNull(obj2.getTheMap()); assertEquals(3,obj1.getTheMap().size()); assertEquals(3,obj2.getTheMap().size()); assertTrue(obj1.getTheMap().get("rainy")); assertTrue(obj2.getTheMap().get("rainy")); assertFalse(obj1.getTheMap().get("sunny")); assertFalse(obj2.getTheMap().get("sunny")); assertFalse(obj2.getTheMap().get("cloudy")); }

InternalCallVerifier EqualityVerifier 
@Test public void testInvocations() throws Exception { Map lts=clientInterface.getMapLongToString(); assertEquals("twenty-seven",lts.get(Long.valueOf(27))); }

Class: org.apache.cxf.aegis.type.streams.XMLStreamReaderMappingTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testReadStream() throws Exception { InputStream is=getResourceAsStream("bean1.xml"); XMLInputFactory inputFactory=XMLInputFactory.newInstance(); XMLStreamReader inputReader=inputFactory.createXMLStreamReader(is); AegisReader reader=context.createXMLStreamReader(); Object what=reader.read(inputReader); assertTrue(what instanceof XMLStreamReader); XMLStreamReader beanReader=(XMLStreamReader)what; beanReader.nextTag(); assertEquals("bleh",beanReader.getLocalName()); }

Class: org.apache.cxf.attachment.AttachmentDeserializerTest

APIUtilityVerifier IterativeVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testLazyAttachmentCollection() throws Exception { InputStream is=getClass().getResourceAsStream("mimedata2"); String ct="multipart/related; type=\"application/xop+xml\"; " + "start=\"\"; " + "start-info=\"text/xml; charset=utf-8\"; "+ "boundary=\"----=_Part_4_701508.1145579811786\""; msg.put(Message.CONTENT_TYPE,ct); msg.setContent(InputStream.class,is); AttachmentDeserializer deserializer=new AttachmentDeserializer(msg); deserializer.initializeAttachments(); InputStream attBody=msg.getContent(InputStream.class); assertTrue(attBody != is); assertTrue(attBody instanceof DelegatingInputStream); attBody.close(); assertEquals(2,msg.getAttachments().size()); List cidlist=new ArrayList(); cidlist.add("xfire_logo.jpg"); cidlist.add("xfire_logo2.jpg"); for (Iterator it=msg.getAttachments().iterator(); it.hasNext(); ) { Attachment a=it.next(); assertTrue(cidlist.remove(a.getId())); it.remove(); } assertEquals(0,cidlist.size()); assertEquals(0,msg.getAttachments().size()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testCXF3582c() throws Exception { String contentType="multipart/related; type=\"application/xop+xml\"; " + "boundary=\"uuid:906fa67b-85f9-4ef5-8e3d-52416022d463\"; " + "start=\"\"; start-info=\"text/xml\""; Message message=new MessageImpl(); message.put(Message.CONTENT_TYPE,contentType); message.setContent(InputStream.class,getClass().getResourceAsStream("cxf3582.data")); message.put(AttachmentDeserializer.ATTACHMENT_DIRECTORY,System.getProperty("java.io.tmpdir")); message.put(AttachmentDeserializer.ATTACHMENT_MEMORY_THRESHOLD,String.valueOf(AttachmentDeserializer.THRESHOLD)); AttachmentDeserializer ad=new AttachmentDeserializer(message,Collections.singletonList("multipart/related")); ad.initializeAttachments(); String cid="1a66bb35-67fc-4e89-9f33-48af417bf9fe-1@apache.org"; DataSource ds=AttachmentUtil.getAttachmentDataSource(cid,message.getAttachments()); byte bts[]=new byte[1024]; InputStream ins=ds.getInputStream(); int count=0; int x=ins.read(bts,100,600); while (x != -1) { count+=x; x=ins.read(bts,100,600); } assertEquals(500,count); assertEquals(-1,ins.read(new byte[1000],100,600)); cid="1a66bb35-67fc-4e89-9f33-48af417bf9fe-2@apache.org"; ds=AttachmentUtil.getAttachmentDataSource(cid,message.getAttachments()); bts=new byte[1024]; ins=ds.getInputStream(); count=0; x=ins.read(bts,100,600); while (x != -1) { count+=x; x=ins.read(bts,100,600); } assertEquals(1249,count); assertEquals(-1,ins.read(new byte[1000],100,600)); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testCXF3582b() throws Exception { String contentType="multipart/related; type=\"application/xop+xml\"; " + "boundary=\"uuid:906fa67b-85f9-4ef5-8e3d-52416022d463\"; " + "start=\"\"; start-info=\"text/xml\""; Message message=new MessageImpl(); message.put(Message.CONTENT_TYPE,contentType); message.setContent(InputStream.class,getClass().getResourceAsStream("cxf3582.data")); message.put(AttachmentDeserializer.ATTACHMENT_DIRECTORY,System.getProperty("java.io.tmpdir")); message.put(AttachmentDeserializer.ATTACHMENT_MEMORY_THRESHOLD,String.valueOf(AttachmentDeserializer.THRESHOLD)); AttachmentDeserializer ad=new AttachmentDeserializer(message,Collections.singletonList("multipart/related")); ad.initializeAttachments(); String cid="1a66bb35-67fc-4e89-9f33-48af417bf9fe-1@apache.org"; DataSource ds=AttachmentUtil.getAttachmentDataSource(cid,message.getAttachments()); byte bts[]=new byte[1024]; InputStream ins=ds.getInputStream(); int count=0; int x=ins.read(bts,500,200); while (x != -1) { count+=x; x=ins.read(bts,500,200); } assertEquals(500,count); assertEquals(-1,ins.read(new byte[1000],500,500)); cid="1a66bb35-67fc-4e89-9f33-48af417bf9fe-2@apache.org"; ds=AttachmentUtil.getAttachmentDataSource(cid,message.getAttachments()); bts=new byte[1024]; ins=ds.getInputStream(); count=0; x=ins.read(bts,500,200); while (x != -1) { count+=x; x=ins.read(bts,500,200); } assertEquals(1249,count); assertEquals(-1,ins.read(new byte[1000],500,500)); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDeserializerMtomWithAxis2StyleBoundaries() throws Exception { InputStream is=getClass().getResourceAsStream("axis2_mimedata"); String ct="multipart/related; type=\"application/xop+xml\"; " + "start=\"\"; " + "start-info=\"text/xml; charset=utf-8\"; "+ "boundary=MIMEBoundaryurn_uuid_6BC4984D5D38EB283C1177616488109"; msg.put(Message.CONTENT_TYPE,ct); msg.setContent(InputStream.class,is); AttachmentDeserializer deserializer=new AttachmentDeserializer(msg); deserializer.initializeAttachments(); InputStream attBody=msg.getContent(InputStream.class); assertTrue(attBody != is); assertTrue(attBody instanceof DelegatingInputStream); Collection atts=msg.getAttachments(); assertNotNull(atts); Iterator itr=atts.iterator(); assertTrue(itr.hasNext()); Attachment a=itr.next(); assertNotNull(a); InputStream attIs=a.getDataHandler().getInputStream(); ByteArrayOutputStream out=new ByteArrayOutputStream(); IOUtils.copy(attBody,out); assertTrue(out.toString().startsWith("

InternalCallVerifier EqualityVerifier 
@Test public void testSmallStream() throws Exception { byte[] messageBytes=("------=_Part_1\n\nJJJJ\n------=_Part_1\n\n" + "Content-Transfer-Encoding: binary\n\n=3D=3D=3D\n------=_Part_1\n").getBytes(); PushbackInputStream pushbackStream=new PushbackInputStream(new ByteArrayInputStream(messageBytes),2048); pushbackStream.read(new byte[4096],0,4015); pushbackStream.unread(messageBytes); pushbackStream.read(new byte[72]); MimeBodyPartInputStream m=new MimeBodyPartInputStream(pushbackStream,"------=_Part_1".getBytes(),2048); assertEquals(10,m.read(new byte[1000])); assertEquals(-1,m.read(new byte[1000])); assertEquals(-1,m.read(new byte[1000])); m.close(); }

APIUtilityVerifier IterativeVerifier BooleanVerifier InternalCallVerifier EqualityVerifier PublicFieldVerifier HybridVerifier 
@Test public void testCXF3383() throws Exception { String contentType="multipart/related; type=\"application/xop+xml\";" + " boundary=\"uuid:7a555f51-c9bb-4bd4-9929-706899e2f793\"; start=" + "\"\"; start-info=\"text/xml\""; Message message=new MessageImpl(); message.put(Message.CONTENT_TYPE,contentType); message.setContent(InputStream.class,getClass().getResourceAsStream("cxf3383.data")); message.put(AttachmentDeserializer.ATTACHMENT_DIRECTORY,System.getProperty("java.io.tmpdir")); message.put(AttachmentDeserializer.ATTACHMENT_MEMORY_THRESHOLD,String.valueOf(AttachmentDeserializer.THRESHOLD)); AttachmentDeserializer ad=new AttachmentDeserializer(message,Collections.singletonList("multipart/related")); ad.initializeAttachments(); for (int x=1; x < 50; x++) { String cid="1882f79d-e20a-4b36-a222-7a75518cf395-" + x + "@cxf.apache.org"; DataSource ds=AttachmentUtil.getAttachmentDataSource(cid,message.getAttachments()); byte bts[]=new byte[1024]; InputStream ins=ds.getInputStream(); int count=0; int sz=ins.read(bts,0,bts.length); while (sz != -1) { count+=sz; assertTrue(count < bts.length); sz=ins.read(bts,count,bts.length - count); } assertEquals(x + 1,count); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier PublicFieldVerifier 
@Test public void testCXF3582() throws Exception { String contentType="multipart/related; type=\"application/xop+xml\"; " + "boundary=\"uuid:906fa67b-85f9-4ef5-8e3d-52416022d463\"; " + "start=\"\"; start-info=\"text/xml\""; Message message=new MessageImpl(); message.put(Message.CONTENT_TYPE,contentType); message.setContent(InputStream.class,getClass().getResourceAsStream("cxf3582.data")); message.put(AttachmentDeserializer.ATTACHMENT_DIRECTORY,System.getProperty("java.io.tmpdir")); message.put(AttachmentDeserializer.ATTACHMENT_MEMORY_THRESHOLD,String.valueOf(AttachmentDeserializer.THRESHOLD)); AttachmentDeserializer ad=new AttachmentDeserializer(message,Collections.singletonList("multipart/related")); ad.initializeAttachments(); String cid="1a66bb35-67fc-4e89-9f33-48af417bf9fe-1@apache.org"; DataSource ds=AttachmentUtil.getAttachmentDataSource(cid,message.getAttachments()); byte bts[]=new byte[1024]; InputStream ins=ds.getInputStream(); int count=ins.read(bts,0,bts.length); assertEquals(500,count); assertEquals(-1,ins.read(new byte[1000],500,500)); cid="1a66bb35-67fc-4e89-9f33-48af417bf9fe-2@apache.org"; ds=AttachmentUtil.getAttachmentDataSource(cid,message.getAttachments()); bts=new byte[1024]; ins=ds.getInputStream(); count=ins.read(bts,0,bts.length); assertEquals(1024,count); assertEquals(225,ins.read(new byte[1000],500,500)); assertEquals(-1,ins.read(new byte[1000],500,500)); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDeserializerMtom() throws Exception { InputStream is=getClass().getResourceAsStream("mimedata"); String ct="multipart/related; type=\"application/xop+xml\"; " + "start=\"\"; " + "start-info=\"text/xml; charset=utf-8\"; "+ "boundary=\"----=_Part_4_701508.1145579811786\""; msg.put(Message.CONTENT_TYPE,ct); msg.setContent(InputStream.class,is); AttachmentDeserializer deserializer=new AttachmentDeserializer(msg); deserializer.initializeAttachments(); InputStream attBody=msg.getContent(InputStream.class); assertTrue(attBody != is); assertTrue(attBody instanceof DelegatingInputStream); Collection atts=msg.getAttachments(); assertNotNull(atts); Iterator itr=atts.iterator(); assertTrue(itr.hasNext()); Attachment a=itr.next(); assertNotNull(a); InputStream attIs=a.getDataHandler().getInputStream(); ByteArrayOutputStream out=new ByteArrayOutputStream(); IOUtils.copy(attBody,out); assertTrue(out.toString().startsWith("

InternalCallVerifier EqualityVerifier 
@Test public void testDoesntReturnZero() throws Exception { String contentType="multipart/mixed;boundary=----=_Part_1"; byte[] messageBytes=("------=_Part_1\n\n" + "JJJJ\n" + "------=_Part_1"+ "\n\nContent-Transfer-Encoding: binary\n\n"+ "ABCD1\r\n"+ "------=_Part_1"+ "\n\nContent-Transfer-Encoding: binary\n\n"+ "ABCD2\r\n"+ "------=_Part_1"+ "\n\nContent-Transfer-Encoding: binary\n\n"+ "ABCD3\r\n"+ "------=_Part_1--").getBytes(StandardCharsets.UTF_8); ByteArrayInputStream in=new ByteArrayInputStream(messageBytes){ public int read( byte[] b, int off, int len){ return super.read(b,off,len >= 2 ? 2 : len); } } ; Message message=new MessageImpl(); message.put(Message.CONTENT_TYPE,contentType); message.setContent(InputStream.class,in); message.put(AttachmentDeserializer.ATTACHMENT_DIRECTORY,System.getProperty("java.io.tmpdir")); message.put(AttachmentDeserializer.ATTACHMENT_MEMORY_THRESHOLD,String.valueOf(AttachmentDeserializer.THRESHOLD)); AttachmentDeserializer ad=new AttachmentDeserializer(message,Collections.singletonList("multipart/mixed")); ad.initializeAttachments(); String s=getString(message.getContent(InputStream.class)); assertEquals("JJJJ",s.trim()); int count=1; for ( Attachment a : message.getAttachments()) { s=getString(a.getDataHandler().getInputStream()); assertEquals("ABCD" + count++,s); } }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testNoBoundaryInCT() throws Exception { String message="SomeHeader: foo\n" + "------=_Part_34950_1098328613.1263781527359\n" + "Content-Type: text/xml; charset=UTF-8\n"+ "Content-Transfer-Encoding: binary\n"+ "Content-Id: <318731183421.1263781527359.IBM.WEBSERVICES@auhpap02>\n"+ "\n"+ "\n"+ "------=_Part_34950_1098328613.1263781527359\n"+ "Content-Type: text/xml\n"+ "Content-Transfer-Encoding: binary\n"+ "Content-Id: \n"+ "\n"+ "\n"+ "------=_Part_34950_1098328613.1263781527359--"; Matcher m=Pattern.compile("^--(\\S*)$").matcher(message); Assert.assertFalse(m.find()); m=Pattern.compile("^--(\\S*)$",Pattern.MULTILINE).matcher(message); Assert.assertTrue(m.find()); msg=new MessageImpl(); msg.setContent(InputStream.class,new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8))); msg.put(Message.CONTENT_TYPE,"multipart/related"); AttachmentDeserializer ad=new AttachmentDeserializer(msg); ad.initializeAttachments(); assertEquals(1,msg.getAttachments().size()); }

Class: org.apache.cxf.attachment.AttachmentSerializerTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testMessageMTOM() throws Exception { MessageImpl msg=new MessageImpl(); Collection atts=new ArrayList(); AttachmentImpl a=new AttachmentImpl("test.xml"); InputStream is=getClass().getResourceAsStream("my.wav"); ByteArrayDataSource ds=new ByteArrayDataSource(is,"application/octet-stream"); a.setDataHandler(new DataHandler(ds)); atts.add(a); msg.setAttachments(atts); msg.put(Message.CONTENT_TYPE,"application/soap+xml"); ByteArrayOutputStream out=new ByteArrayOutputStream(); msg.setContent(OutputStream.class,out); AttachmentSerializer serializer=new AttachmentSerializer(msg); serializer.writeProlog(); String ct=(String)msg.get(Message.CONTENT_TYPE); assertTrue(ct.indexOf("multipart/related;") == 0); assertTrue(ct.indexOf("start=\"\"") > -1); assertTrue(ct.indexOf("start-info=\"application/soap+xml\"") > -1); out.write("".getBytes()); serializer.writeAttachments(); out.flush(); DataSource source=new ByteArrayDataSource(new ByteArrayInputStream(out.toByteArray()),ct); MimeMultipart mpart=new MimeMultipart(source); Session session=Session.getDefaultInstance(new Properties()); MimeMessage inMsg=new MimeMessage(session); inMsg.setContent(mpart); inMsg.addHeaderLine("Content-Type: " + ct); MimeMultipart multipart=(MimeMultipart)inMsg.getContent(); MimeBodyPart part=(MimeBodyPart)multipart.getBodyPart(0); assertEquals("application/xop+xml; charset=UTF-8; type=\"application/soap+xml\"",part.getHeader("Content-Type")[0]); assertEquals("binary",part.getHeader("Content-Transfer-Encoding")[0]); assertEquals("",part.getHeader("Content-ID")[0]); InputStream in=part.getDataHandler().getInputStream(); ByteArrayOutputStream bodyOut=new ByteArrayOutputStream(); IOUtils.copy(in,bodyOut); out.close(); in.close(); assertEquals("",bodyOut.toString()); MimeBodyPart part2=(MimeBodyPart)multipart.getBodyPart(1); assertEquals("application/octet-stream",part2.getHeader("Content-Type")[0]); assertEquals("binary",part2.getHeader("Content-Transfer-Encoding")[0]); assertEquals("",part2.getHeader("Content-ID")[0]); }

Class: org.apache.cxf.attachment.AttachmentUtilTest

EqualityVerifier 
@Test public void testContendDispositionFileNameKanjiChars(){ assertEquals("世界ーファイル.txt",AttachmentUtil.getContentDispositionFileName("filename*=UTF-8''%e4%b8%96%e7%95%8c%e3%83%bc%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab.txt")); }

EqualityVerifier 
@Test public void testContendDispositionFileNameWithQuotesAndSemicolon3(){ assertEquals("a;txt",AttachmentUtil.getContentDispositionFileName("name=\"a\";filename=\"a;txt\"")); }

EqualityVerifier 
@Test public void testContendDispositionFileNameSpacesNoQuotes(){ assertEquals("a.txt",AttachmentUtil.getContentDispositionFileName("form-data; filename = a.txt")); }

EqualityVerifier 
@Test public void testContendDispositionFileNameWithQuotesAndSemicolon2(){ assertEquals("a;txt",AttachmentUtil.getContentDispositionFileName("filename=\"a;txt\"")); }

EqualityVerifier 
@Test public void testContendDispositionFileNameWithQuotes(){ assertEquals("a.txt",AttachmentUtil.getContentDispositionFileName("form-data; filename=\"a.txt\"")); }

EqualityVerifier 
@Test public void testContendDispositionFileNameNoQuotes(){ assertEquals("a.txt",AttachmentUtil.getContentDispositionFileName("form-data; filename=a.txt")); }

EqualityVerifier 
@Test public void testContendDispositionFileNameNoQuotesAndType(){ assertEquals("a.txt",AttachmentUtil.getContentDispositionFileName("filename=a.txt")); }

EqualityVerifier 
@Test public void testContendDispositionFileNameWithQuotesAndSemicolon(){ assertEquals("a;txt",AttachmentUtil.getContentDispositionFileName("form-data; filename=\"a;txt\"")); }

EqualityVerifier 
@Test public void testContendDispositionFileNameNoQuotesAndType2(){ assertEquals("a.txt",AttachmentUtil.getContentDispositionFileName("name=files; filename=a.txt")); }

Class: org.apache.cxf.attachment.Rfc5987UtilTest

EqualityVerifier 
@Test public void test() throws Exception { assertEquals(expected,Rfc5987Util.encode(input,StandardCharsets.UTF_8.name())); assertEquals(input,Rfc5987Util.decode(expected,StandardCharsets.UTF_8.name())); }

Class: org.apache.cxf.binding.coloc.ColocMessageObserverTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testObserverOnMessage() throws Exception { msg.setExchange(ex); Binding binding=control.createMock(Binding.class); EasyMock.expect(ep.getBinding()).andReturn(binding); Message inMsg=new MessageImpl(); EasyMock.expect(binding.createMessage()).andReturn(inMsg); EasyMock.expect(ep.getService()).andReturn(srv).anyTimes(); EasyMock.expect(bus.getExtension(PhaseManager.class)).andReturn(new PhaseManagerImpl()).times(2); EasyMock.expect(bus.getInInterceptors()).andReturn(new ArrayList>()); EasyMock.expect(ep.getInInterceptors()).andReturn(new ArrayList>()); EasyMock.expect(srv.getInInterceptors()).andReturn(new ArrayList>()); EasyMock.expect(bus.getExtension(ClassLoader.class)).andReturn(this.getClass().getClassLoader()); control.replay(); observer=new TestColocMessageObserver(ep,bus); observer.onMessage(msg); control.verify(); Exchange inEx=inMsg.getExchange(); assertNotNull("Should Have a valid Exchange",inEx); assertEquals("Message.REQUESTOR_ROLE should be false",Boolean.FALSE,inMsg.get(Message.REQUESTOR_ROLE)); assertEquals("Message.INBOUND_MESSAGE should be true",Boolean.TRUE,inMsg.get(Message.INBOUND_MESSAGE)); assertNotNull("Chain should be set",inMsg.getInterceptorChain()); Exchange ex1=msg.getExchange(); assertNotNull("Exchange should be set",ex1); }

Class: org.apache.cxf.binding.coloc.ColocOutInterceptorTest

InternalCallVerifier IdentityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testInvokeInboundChain(){ msg.setExchange(null); Bus bus=setupBus(); colocOut.setBus(bus); PhaseManager pm=new PhaseManagerImpl(); EasyMock.expect(bus.getExtension(PhaseManager.class)).andReturn(pm).times(2); Endpoint ep=control.createMock(Endpoint.class); Binding bd=control.createMock(Binding.class); Service srv=control.createMock(Service.class); ex.setInMessage(msg); ex.put(Bus.class,bus); ex.put(Endpoint.class,ep); ex.put(Service.class,srv); EasyMock.expect(ep.getBinding()).andReturn(bd); EasyMock.expect(bd.createMessage()).andReturn(new MessageImpl()); EasyMock.expect(ep.getInInterceptors()).andReturn(new ArrayList>()).atLeastOnce(); EasyMock.expect(ep.getService()).andReturn(srv).atLeastOnce(); EasyMock.expect(srv.getInInterceptors()).andReturn(new ArrayList>()).atLeastOnce(); EasyMock.expect(bus.getInInterceptors()).andReturn(new ArrayList>()).atLeastOnce(); control.replay(); colocOut.invokeInboundChain(ex,ep); Message inMsg=ex.getInMessage(); assertNotSame(msg,inMsg); assertEquals("Requestor role should be set to true.",Boolean.TRUE,inMsg.get(Message.REQUESTOR_ROLE)); assertEquals("Inbound Message should be set to true.",Boolean.TRUE,inMsg.get(Message.INBOUND_MESSAGE)); assertNotNull("Inbound Message should have interceptor chain set.",inMsg.getInterceptorChain()); assertEquals("Client Invoke state should be FINISHED",Boolean.TRUE,ex.get(ClientImpl.FINISHED)); control.verify(); }

EqualityVerifier 
@Test public void testColocOutPhase() throws Exception { assertEquals(Phase.POST_LOGICAL,colocOut.getPhase()); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testColocOutInvalidServiceRegistry() throws Exception { setupBus(); try { colocOut.handleMessage(msg); fail("Should have thrown a fault"); } catch ( Fault f) { assertEquals("Server Registry not registered with bus.",f.getMessage()); } }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testColocOutInvalidEndpoint() throws Exception { Bus bus=setupBus(); ServerRegistry sr=control.createMock(ServerRegistry.class); EasyMock.expect(bus.getExtension(ServerRegistry.class)).andReturn(sr); control.replay(); try { colocOut.handleMessage(msg); fail("Should have thrown a fault"); } catch ( Fault f) { assertEquals("Consumer Endpoint not found in exchange.",f.getMessage()); } }

InternalCallVerifier EqualityVerifier 
@Test public void testColocOutIsColocatedPropertySet() throws Exception { colocOut=new TestColocOutInterceptor1(); Bus bus=setupBus(); ServerRegistry sr=control.createMock(ServerRegistry.class); EasyMock.expect(bus.getExtension(ServerRegistry.class)).andReturn(sr); Server s1=control.createMock(Server.class); List list=new ArrayList(); list.add(s1); Endpoint sep=control.createMock(Endpoint.class); ex.put(Endpoint.class,sep); QName op=new QName("E","F"); QName intf=new QName("G","H"); BindingInfo sbi=control.createMock(BindingInfo.class); ServiceInfo ssi=new ServiceInfo(); InterfaceInfo sii=new InterfaceInfo(ssi,intf); sii.addOperation(op); OperationInfo soi=sii.getOperation(op); ServiceInfo rsi=new ServiceInfo(); InterfaceInfo rii=new InterfaceInfo(rsi,intf); rii.addOperation(op); OperationInfo roi=rii.getOperation(op); BindingOperationInfo sboi=control.createMock(BindingOperationInfo.class); BindingOperationInfo rboi=control.createMock(BindingOperationInfo.class); ex.put(BindingOperationInfo.class,sboi); Service ses=control.createMock(Service.class); EndpointInfo sei=control.createMock(EndpointInfo.class); Endpoint rep=control.createMock(Endpoint.class); Service res=control.createMock(Service.class); BindingInfo rbi=control.createMock(BindingInfo.class); EndpointInfo rei=control.createMock(EndpointInfo.class); EasyMock.expect(sr.getServers()).andReturn(list); EasyMock.expect(sep.getService()).andReturn(ses); EasyMock.expect(sep.getEndpointInfo()).andReturn(sei); EasyMock.expect(s1.getEndpoint()).andReturn(rep); EasyMock.expect(rep.getService()).andReturn(res); EasyMock.expect(rep.getEndpointInfo()).andReturn(rei); EasyMock.expect(ses.getName()).andReturn(new QName("A","B")); EasyMock.expect(res.getName()).andReturn(new QName("A","B")); EasyMock.expect(rei.getName()).andReturn(new QName("C","D")); EasyMock.expect(sei.getName()).andReturn(new QName("C","D")); EasyMock.expect(rei.getBinding()).andReturn(rbi); EasyMock.expect(sboi.getName()).andReturn(op).anyTimes(); EasyMock.expect(sboi.getOperationInfo()).andReturn(soi); EasyMock.expect(rboi.getName()).andReturn(op).anyTimes(); EasyMock.expect(rboi.getOperationInfo()).andReturn(roi); EasyMock.expect(rbi.getOperation(op)).andReturn(rboi); InterceptorChain chain=control.createMock(InterceptorChain.class); msg.setInterceptorChain(chain); EasyMock.expect(sboi.getBinding()).andReturn(sbi); EasyMock.expect(sbi.getInterface()).andReturn(sii); control.replay(); colocOut.handleMessage(msg); assertEquals("COLOCATED property should be set",Boolean.TRUE,msg.get(COLOCATED)); assertEquals("Message.WSDL_OPERATION property should be set",op,msg.get(Message.WSDL_OPERATION)); assertEquals("Message.WSDL_INTERFACE property should be set",intf,msg.get(Message.WSDL_INTERFACE)); control.verify(); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testColocOutInvalidOperation() throws Exception { Bus bus=setupBus(); ServerRegistry sr=control.createMock(ServerRegistry.class); EasyMock.expect(bus.getExtension(ServerRegistry.class)).andReturn(sr); Endpoint ep=control.createMock(Endpoint.class); ex.put(Endpoint.class,ep); control.replay(); try { colocOut.handleMessage(msg); fail("Should have thrown a fault"); } catch ( Fault f) { assertEquals("Operation not found in exchange.",f.getMessage()); } }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testColocOutInvalidBus() throws Exception { try { colocOut.handleMessage(msg); fail("Should have thrown a fault"); } catch ( Fault f) { assertEquals("Bus not created or not set as default bus.",f.getMessage()); } }

Class: org.apache.cxf.binding.coloc.ColocUtilTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testIsSameMessageInfo(){ OperationInfo oi=control.createMock(OperationInfo.class); boolean match=ColocUtil.isSameMessageInfo(null,null); assertEquals("Should return true",true,match); QName mn1=new QName("A","B"); QName mn2=new QName("C","D"); MessageInfo mi1=new MessageInfo(oi,MessageInfo.Type.INPUT,mn1); MessageInfo mi2=new MessageInfo(oi,MessageInfo.Type.INPUT,mn2); match=ColocUtil.isSameMessageInfo(mi1,null); assertEquals("Should not find a match",false,match); match=ColocUtil.isSameMessageInfo(null,mi2); assertEquals("Should not find a match",false,match); MessagePartInfo mpi=new MessagePartInfo(new QName("","B"),null); mpi.setTypeClass(InHeaderT.class); mi1.addMessagePart(mpi); mpi=new MessagePartInfo(new QName("","D"),null); mpi.setTypeClass(OutHeaderT.class); mi2.addMessagePart(mpi); match=ColocUtil.isSameMessageInfo(mi1,mi2); assertEquals("Should not find a match",false,match); mpi.setTypeClass(InHeaderT.class); match=ColocUtil.isSameMessageInfo(mi1,mi2); assertEquals("Should find a match",true,match); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetOutInterceptorChain() throws Exception { PhaseManagerImpl phaseMgr=new PhaseManagerImpl(); SortedSet list=phaseMgr.getInPhases(); ColocUtil.setPhases(list,Phase.SETUP,Phase.POST_LOGICAL); Endpoint ep=control.createMock(Endpoint.class); Service srv=control.createMock(Service.class); Exchange ex=new ExchangeImpl(); ex.put(Bus.class,bus); ex.put(Endpoint.class,ep); ex.put(Service.class,srv); EasyMock.expect(ep.getOutInterceptors()).andReturn(new ArrayList>()).atLeastOnce(); EasyMock.expect(ep.getService()).andReturn(srv).atLeastOnce(); EasyMock.expect(srv.getOutInterceptors()).andReturn(new ArrayList>()).atLeastOnce(); EasyMock.expect(bus.getOutInterceptors()).andReturn(new ArrayList>()).atLeastOnce(); control.replay(); InterceptorChain chain=ColocUtil.getOutInterceptorChain(ex,list); control.verify(); assertNotNull("Should have chain instance",chain); Iterator> iter=chain.iterator(); assertEquals("Should not have interceptors in chain",false,iter.hasNext()); }

APIUtilityVerifier InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testSetColocOutPhases() throws Exception { PhaseManagerImpl phaseMgr=new PhaseManagerImpl(); SortedSet list=phaseMgr.getOutPhases(); int size1=list.size(); ColocUtil.setPhases(list,Phase.SETUP,Phase.POST_LOGICAL); assertNotSame("The list size should not be same",size1,list.size()); assertEquals("Expecting Phase.SETUP",list.first().getName(),Phase.SETUP); assertEquals("Expecting Phase.POST_LOGICAL",list.last().getName(),Phase.POST_LOGICAL); }

APIUtilityVerifier InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testSetColocInPhases() throws Exception { PhaseManagerImpl phaseMgr=new PhaseManagerImpl(); SortedSet list=phaseMgr.getInPhases(); int size1=list.size(); ColocUtil.setPhases(list,Phase.USER_LOGICAL,Phase.INVOKE); assertNotSame("The list size should not be same",size1,list.size()); assertEquals("Expecting Phase.USER_LOGICAL",list.first().getName(),Phase.USER_LOGICAL); assertEquals("Expecting Phase.POST_INVOKE",list.last().getName(),Phase.INVOKE); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetInInterceptorChain() throws Exception { PhaseManagerImpl phaseMgr=new PhaseManagerImpl(); SortedSet list=phaseMgr.getInPhases(); ColocUtil.setPhases(list,Phase.SETUP,Phase.POST_LOGICAL); Endpoint ep=control.createMock(Endpoint.class); Service srv=control.createMock(Service.class); Exchange ex=new ExchangeImpl(); ex.put(Bus.class,bus); ex.put(Endpoint.class,ep); ex.put(Service.class,srv); EasyMock.expect(bus.getExtension(PhaseManager.class)).andReturn(phaseMgr); EasyMock.expect(ep.getInInterceptors()).andReturn(new ArrayList>()).atLeastOnce(); EasyMock.expect(ep.getService()).andReturn(srv).atLeastOnce(); EasyMock.expect(srv.getInInterceptors()).andReturn(new ArrayList>()).atLeastOnce(); EasyMock.expect(bus.getInInterceptors()).andReturn(new ArrayList>()).atLeastOnce(); control.replay(); InterceptorChain chain=ColocUtil.getInInterceptorChain(ex,list); control.verify(); assertNotNull("Should have chain instance",chain); Iterator> iter=chain.iterator(); assertEquals("Should not have interceptors in chain",false,iter.hasNext()); assertNotNull("OutFaultObserver should be set",chain.getFaultObserver()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testIsSameFaultInfo(){ OperationInfo oi=control.createMock(OperationInfo.class); boolean match=ColocUtil.isSameFaultInfo(null,null); assertEquals("Should return true",true,match); List fil1=new ArrayList(); match=ColocUtil.isSameFaultInfo(fil1,null); assertEquals("Should not find a match",false,match); match=ColocUtil.isSameFaultInfo(null,fil1); assertEquals("Should not find a match",false,match); List fil2=new ArrayList(); match=ColocUtil.isSameFaultInfo(fil1,fil2); QName fn1=new QName("A","B"); QName fn2=new QName("C","D"); FaultInfo fi1=new FaultInfo(fn1,null,oi); fi1.setProperty(Class.class.getName(),PingMeFault.class); fil1.add(fi1); FaultInfo fi2=new FaultInfo(fn2,null,oi); fi2.setProperty(Class.class.getName(),FaultDetailT.class); match=ColocUtil.isSameFaultInfo(fil1,fil2); assertEquals("Should not find a match",false,match); FaultInfo fi3=new FaultInfo(fn2,null,oi); fi3.setProperty(Class.class.getName(),PingMeFault.class); fil2.add(fi3); match=ColocUtil.isSameFaultInfo(fil1,fil2); assertEquals("Should find a match",true,match); }

Class: org.apache.cxf.binding.corba.CorbaBindingFactoryTest

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCreateBinding() throws Exception { IMocksControl control=EasyMock.createNiceControl(); BindingInfo bindingInfo=control.createMock(BindingInfo.class); CorbaBinding binding=(CorbaBinding)factory.createBinding(bindingInfo); assertNotNull(binding); assertTrue(CorbaBinding.class.isInstance(binding)); List> inInterceptors=binding.getInInterceptors(); assertNotNull(inInterceptors); List> outInterceptors=binding.getOutInterceptors(); assertNotNull(outInterceptors); assertEquals(2,inInterceptors.size()); assertEquals(2,outInterceptors.size()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testTransportIds() throws Exception { setupServiceInfo("http://cxf.apache.org/bindings/corba/simple","/wsdl_corbabinding/simpleIdl.wsdl","SimpleCORBAService","SimpleCORBAPort"); List strs=new ArrayList(); strs.add("one"); strs.add("two"); factory.setTransportIds(strs); List retStrs=factory.getTransportIds(); assertNotNull(retStrs); String str=retStrs.get(0); assertEquals("one",str.toString()); str=retStrs.get(1); assertEquals("two",str.toString()); }

Class: org.apache.cxf.binding.corba.CorbaConduitTest

InternalCallVerifier EqualityVerifier 
@Test public void testGetOperationExceptions(){ CorbaConduit conduit=control.createMock(CorbaConduit.class); OperationType opType=control.createMock(OperationType.class); CorbaTypeMap typeMap=control.createMock(CorbaTypeMap.class); List exlist=CastUtils.cast(control.createMock(ArrayList.class)); opType.getRaises(); EasyMock.expectLastCall().andReturn(exlist); int i=0; EasyMock.expect(exlist.size()).andReturn(i); RaisesType rType=control.createMock(RaisesType.class); EasyMock.expect(exlist.get(0)).andReturn(rType); control.replay(); conduit.getOperationExceptions(opType,typeMap); assertEquals(exlist.size(),0); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBuildExceptionListEmpty() throws Exception { CorbaConduit conduit=setupCorbaConduit(false); Message msg=new MessageImpl(); CorbaMessage message=new CorbaMessage(msg); OperationType opType=new OperationType(); opType.setName("review_data"); ExceptionList exList=conduit.getExceptionList(conduit.getOperationExceptions(opType,null),message,opType); assertNotNull("ExcepitonList is not null",exList != null); assertEquals("The list should be empty",exList.count(),0); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testGetAddress() throws Exception { setupServiceInfo("http://cxf.apache.org/bindings/corba/simple","/wsdl_corbabinding/simpleIdl.wsdl","SimpleCORBAService","SimpleCORBAPort"); CorbaDestination destination=new CorbaDestination(endpointInfo,orbConfig); endpointInfo.setAddress("corbaloc::localhost:40000/Simple"); CorbaConduit conduit=new CorbaConduit(endpointInfo,destination.getAddress(),orbConfig); String address=conduit.getAddress(); assertTrue("address should not be null",address != null); assertEquals(address,"corbaloc::localhost:40000/Simple"); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBuildArguments() throws Exception { Message msg=new MessageImpl(); CorbaMessage message=new CorbaMessage(msg); CorbaStreamable[] arguments=new CorbaStreamable[1]; QName objName=new QName("object"); QName objIdlType=new QName(CorbaConstants.NU_WSDL_CORBA,"short",CorbaConstants.NP_WSDL_CORBA); TypeCode objTypeCode=orb.get_primitive_tc(TCKind.tk_short); CorbaPrimitiveHandler obj1=new CorbaPrimitiveHandler(objName,objIdlType,objTypeCode,null); CorbaStreamable arg=message.createStreamableObject(obj1,objName); arguments[0]=arg; arguments[0].setMode(org.omg.CORBA.ARG_OUT.value); CorbaConduit conduit=setupCorbaConduit(false); NVList list=conduit.getArguments(message); assertNotNull("list should not be null",list != null); message.setStreamableArguments(arguments); NVList listArgs=conduit.getArguments(message); assertNotNull("listArgs should not be null",listArgs != null); assertNotNull("listArgs Item should not be null",listArgs.item(0) != null); assertEquals("Name should be equal",listArgs.item(0).name(),"object"); assertEquals("flags should be 2",listArgs.item(0).flags(),2); assertNotNull("Any Value should not be null",listArgs.item(0).value() != null); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBuildReturn() throws Exception { Message msg=new MessageImpl(); CorbaMessage message=new CorbaMessage(msg); QName objName=new QName("returnName"); QName objIdlType=new QName(CorbaConstants.NU_WSDL_CORBA,"short",CorbaConstants.NP_WSDL_CORBA); TypeCode objTypeCode=orb.get_primitive_tc(TCKind.tk_short); CorbaPrimitiveHandler obj1=new CorbaPrimitiveHandler(objName,objIdlType,objTypeCode,null); CorbaStreamable arg=message.createStreamableObject(obj1,objName); CorbaConduit conduit=setupCorbaConduit(false); NamedValue ret=conduit.getReturn(message); assertNotNull("Return should not be null",ret != null); assertEquals("name should be equal",ret.name(),"return"); message.setStreamableReturn(arg); NamedValue ret2=conduit.getReturn(message); assertNotNull("Return2 should not be null",ret2 != null); assertEquals("name should be equal",ret2.name(),"returnName"); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBuildExceptionListWithExceptions() throws Exception { CorbaConduit conduit=setupCorbaConduit(false); Message msg=new MessageImpl(); CorbaMessage message=new CorbaMessage(msg); TestUtils testUtils=new TestUtils(); CorbaDestination destination=testUtils.getExceptionTypesTestDestination(); EndpointInfo endpointInfo2=destination.getEndPointInfo(); QName name=new QName("http://schemas.apache.org/idl/except","review_data",""); BindingOperationInfo bInfo=destination.getBindingInfo().getOperation(name); OperationType opType=bInfo.getExtensor(OperationType.class); CorbaTypeMap typeMap=null; List corbaTypes=endpointInfo2.getService().getDescription().getExtensors(TypeMappingType.class); if (corbaTypes != null) { typeMap=CorbaUtils.createCorbaTypeMap(corbaTypes); } ExceptionList exList=conduit.getExceptionList(conduit.getOperationExceptions(opType,typeMap),message,opType); assertNotNull("ExceptionList is not null",exList != null); assertNotNull("TypeCode is not null",exList.item(0) != null); assertEquals("ID should be equal",exList.item(0).id(),"IDL:BadRecord:1.0"); assertEquals("ID should be equal",exList.item(0).name(),"BadRecord"); assertEquals("ID should be equal",exList.item(0).member_count(),2); assertEquals("ID should be equal",exList.item(0).member_name(0),"reason"); assertNotNull("Member type is not null",exList.item(0).member_type(0) != null); }

Class: org.apache.cxf.binding.corba.CorbaServerConduitTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testGetAddress() throws Exception { setupServiceInfo("http://cxf.apache.org/bindings/corba/simple","/wsdl_corbabinding/simpleIdl.wsdl","SimpleCORBAService","SimpleCORBAPort"); CorbaDestination destination=new CorbaDestination(endpointInfo,orbConfig); endpointInfo.setAddress("corbaloc::localhost:40000/Simple"); CorbaServerConduit conduit=new CorbaServerConduit(endpointInfo,destination.getAddress(),targetObject,null,orbConfig,corbaTypeMap); String address=conduit.getAddress(); assertTrue("address should not be null",address != null); assertEquals(address,"corbaloc::localhost:40000/Simple"); }

Class: org.apache.cxf.binding.corba.CorbaTypeMapTest

InternalCallVerifier EqualityVerifier 
@Test public void testCorbaTypeMap() throws Exception { CorbaTypeMap typeMap=new CorbaTypeMap("http://yoko.apache.org/ComplexTypes"); String targetNamespace=typeMap.getTargetNamespace(); assertEquals(targetNamespace,"http://yoko.apache.org/ComplexTypes"); QName type=new QName("http://yoko.apache.org/ComplexTypes","xsd1:Test.MultiPart.Colour",""); CorbaType corbaTypeImpl=new CorbaType(); corbaTypeImpl.setType(type); corbaTypeImpl.setName("Test.MultiPart.Colour"); typeMap.addType("Test.MultiPart.Colour",corbaTypeImpl); CorbaType corbatype=typeMap.getType("Test.MultiPart.Colour"); assertEquals(corbatype.getName(),"Test.MultiPart.Colour"); assertEquals(corbatype.getType().getLocalPart(),"xsd1:Test.MultiPart.Colour"); }

Class: org.apache.cxf.binding.corba.runtime.CorbaObjectReaderTest

InternalCallVerifier EqualityVerifier 
@Test public void testReadULongLong(){ OutputStream oStream=orb.create_output_stream(); oStream.write_ulonglong(-1000000000L); InputStream iStream=oStream.create_input_stream(); CorbaObjectReader reader=new CorbaObjectReader(iStream); BigInteger ulonglongValue=reader.readULongLong(); assertEquals(1,ulonglongValue.signum()); }

Class: org.apache.cxf.binding.corba.runtime.CorbaStreamReaderTest

EqualityVerifier 
@Test public void testGetName() throws Exception { EasyMock.expect(mock.getName()).andReturn(new QName("http://foo.org","test")); EasyMock.replay(mock); assertEquals("checking getName ",new QName("http://foo.org","test"),reader.getName()); }

EqualityVerifier 
@Test public void testGetTextCharacters() throws Exception { EasyMock.expect(mock.getText()).andReturn("abcdef"); EasyMock.replay(mock); assertEquals("checking getTextCharacters","abcdef",new String(reader.getTextCharacters())); }

EqualityVerifier 
@Test public void testGetLocalName() throws Exception { EasyMock.expect(mock.getName()).andReturn(new QName("http://foo.org","test")); EasyMock.replay(mock); assertEquals("checking localName ","test",reader.getLocalName()); }

EqualityVerifier 
@Test public void testGetText() throws Exception { EasyMock.expect(mock.getText()).andReturn("abcdef"); EasyMock.replay(mock); assertEquals("checking getText","abcdef",reader.getText()); }

EqualityVerifier 
@Test public void testGetNamespaceURI() throws Exception { EasyMock.expect(mock.getName()).andReturn(new QName("http://foo.org","test")); EasyMock.replay(mock); assertEquals("checking namespace ","http://foo.org",reader.getNamespaceURI()); }

Class: org.apache.cxf.binding.corba.runtime.CorbaStreamWriterTest

EqualityVerifier 
@Test public void writeCharactersTest() throws XMLStreamException { CorbaStreamWriter writer=new CorbaStreamWriter(null,null,null); final String[] pointer=new String[1]; writer.currentTypeListener=new AbstractCorbaTypeListener(null){ @Override public void processCharacters( String text){ pointer[0]=text; } } ; writer.writeCharacters("abcdefghijklmnopqrstuvwxyz".toCharArray(),0,4); assertEquals("abcd",pointer[0]); }

Class: org.apache.cxf.binding.corba.runtime.CorbaStreamableTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testWriteStreamable(){ QName objName=new QName("object"); QName objIdlType=new QName(CorbaConstants.NU_WSDL_CORBA,"wstring",CorbaConstants.NP_WSDL_CORBA); TypeCode objTypeCode=orb.get_primitive_tc(TCKind.tk_wstring); CorbaPrimitiveHandler obj=new CorbaPrimitiveHandler(objName,objIdlType,objTypeCode,null); obj.setValueFromData("TestWString"); CorbaStreamable streamable=new CorbaStreamableImpl(obj,objName); OutputStream oStream=orb.create_output_stream(); streamable._write(oStream); InputStream iStream=oStream.create_input_stream(); String value=iStream.read_wstring(); assertEquals("TestWString",value); }

Class: org.apache.cxf.binding.corba.types.CorbaAnyHandlerTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCorbaAnyHandler(){ Any a=orb.create_any(); a.insert_string("TestMessage"); QName anyName=new QName("AnyHandlerName"); QName anyIdlType=CorbaConstants.NT_CORBA_ANY; TypeCode anyTC=orb.get_primitive_tc(TCKind.from_int(TCKind._tk_any)); CorbaTypeMap tm=new CorbaTypeMap(CorbaConstants.NU_WSDL_CORBA); CorbaAnyHandler anyHandler=new CorbaAnyHandler(anyName,anyIdlType,anyTC,null); anyHandler.setTypeMap(tm); anyHandler.setValue(a); Any resultAny=anyHandler.getValue(); assertNotNull(resultAny); String value=resultAny.extract_string(); assertEquals("TestMessage",value); CorbaTypeMap resultTM=anyHandler.getTypeMap(); assertTrue(resultTM.getTargetNamespace().equals(CorbaConstants.NU_WSDL_CORBA)); }

Class: org.apache.cxf.binding.corba.utils.ContextUtilsTest

InternalCallVerifier EqualityVerifier 
@Test public void testIsRequestor() throws Exception { Message message=new MessageImpl(); message.put("org.apache.cxf.client","org.apache.cxf.client"); assertEquals(ContextUtils.isRequestor(message),true); }

InternalCallVerifier EqualityVerifier 
@Test public void testIsOutbound() throws Exception { Message message=new MessageImpl(); Exchange exchange=new ExchangeImpl(); exchange.setOutMessage(message); message.setExchange(exchange); assertEquals(ContextUtils.isOutbound(message),true); }

Class: org.apache.cxf.binding.object.LocalServerRegistrationTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testServer() throws Exception { BindingFactoryManager bfm=getBus().getExtension(BindingFactoryManager.class); ObjectBindingFactory obj=(ObjectBindingFactory)bfm.getBindingFactory(ObjectBindingFactory.BINDING_ID); obj.setAutoRegisterLocalEndpoint(true); ServerFactoryBean sfb=new ServerFactoryBean(); sfb.setServiceClass(EchoImpl.class); sfb.setAddress("http://localhost:" + TestUtil.getPortNumber(LocalServerRegistrationTest.class) + "/echo"); Server server=sfb.create(); List content=new ArrayList(); content.add("Hello"); ServiceInfo serviceInfo=server.getEndpoint().getEndpointInfo().getService(); BindingInfo bi=serviceInfo.getBindings().iterator().next(); BindingOperationInfo bop=bi.getOperations().iterator().next(); assertNotNull(bop.getOperationInfo()); MessageImpl m=new MessageImpl(); m.setContent(List.class,content); ExchangeImpl ex=new ExchangeImpl(); ex.setInMessage(m); ex.put(BindingOperationInfo.class,bop); Conduit c=getLocalConduit("local://" + server); ex.setConduit(c); new ObjectDispatchOutInterceptor().handleMessage(m); c.setMessageObserver(new MessageObserver(){ public void onMessage( Message message){ response=message; } } ); c.prepare(m); c.close(m); Thread.sleep(1000); assertNotNull(response); List content2=CastUtils.cast((List)response.getContent(List.class)); assertNotNull(content2); assertEquals(1,content2.size()); }

Class: org.apache.cxf.binding.object.ObjectBindingTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testClient() throws Exception { ClientFactoryBean cfb=new ClientFactoryBean(); cfb.setBindingId(ObjectBindingFactory.BINDING_ID); cfb.setServiceClass(EchoImpl.class); cfb.setAddress("local://Echo"); Client client=cfb.create(); final List content=new ArrayList(); content.add("Hello"); final Destination d=getLocalDestination("local://Echo"); d.setMessageObserver(new MessageObserver(){ public void onMessage( Message inMsg){ MessageImpl outMsg=new MessageImpl(); outMsg.setContent(List.class,content); outMsg.put(LocalConduit.DIRECT_DISPATCH,Boolean.TRUE); inMsg.getExchange().setInMessage(outMsg); try { Conduit backChannel=d.getBackChannel(inMsg); backChannel.prepare(outMsg); backChannel.close(outMsg); } catch ( IOException e) { e.printStackTrace(); } } } ); Object[] res=client.invoke("echo",content.toArray()); assertNotNull(res); assertEquals(1,res.length); assertEquals("Hello",res[0]); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testServer() throws Exception { ServerFactoryBean sfb=new ServerFactoryBean(); sfb.setBindingId(ObjectBindingFactory.BINDING_ID); sfb.setServiceClass(EchoImpl.class); sfb.setAddress("local://Echo"); Server server=sfb.create(); List content=new ArrayList(); content.add("Hello"); ServiceInfo serviceInfo=server.getEndpoint().getEndpointInfo().getService(); BindingInfo bi=serviceInfo.getBindings().iterator().next(); BindingOperationInfo bop=bi.getOperations().iterator().next(); assertNotNull(bop.getOperationInfo()); MessageImpl m=new MessageImpl(); m.setContent(List.class,content); ExchangeImpl ex=new ExchangeImpl(); ex.setInMessage(m); ex.put(BindingOperationInfo.class,bop); Conduit c=getLocalConduit("local://Echo"); ex.setConduit(c); new ObjectDispatchOutInterceptor().handleMessage(m); ex.setConduit(c); c.setMessageObserver(new MessageObserver(){ public void onMessage( Message message){ response=message; } } ); c.prepare(m); c.close(m); Thread.sleep(1000); assertNotNull(response); List content2=CastUtils.cast((List)response.getContent(List.class)); assertNotNull(content2); assertEquals(1,content2.size()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testClientServer() throws Exception { ClientFactoryBean cfb=new ClientFactoryBean(); cfb.setBindingId(ObjectBindingFactory.BINDING_ID); cfb.setServiceClass(EchoImpl.class); cfb.setAddress("local://Echo"); Client client=cfb.create(); ServerFactoryBean sfb=new ServerFactoryBean(); sfb.setBindingId(ObjectBindingFactory.BINDING_ID); sfb.setServiceClass(EchoImpl.class); sfb.setAddress("local://Echo"); sfb.create(); Object[] res=client.invoke("echo",new Object[]{"Hello"}); assertNotNull(res); assertEquals(1,res.length); assertEquals("Hello",res[0]); }

Class: org.apache.cxf.binding.soap.MustUnderstandInterceptorTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testHandleMessageSucc() throws Exception { prepareSoapMessage("test-soap-header.xml"); dsi.getUnderstoodHeaders().add(RESERVATION); dsi.getUnderstoodHeaders().add(PASSENGER); soapMessage.getInterceptorChain().doIntercept(soapMessage); assertEquals("DummaySoapInterceptor getRoles has been called!",true,dsi.isCalledGetRoles()); assertEquals("DummaySoapInterceptor getUnderstood has been called!",true,dsi.isCalledGetUnderstood()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testHandleMessageWithSoapHeader11Param() throws Exception { prepareSoapMessage("test-soap-header.xml"); dsi.getUnderstoodHeaders().add(RESERVATION); ServiceInfo serviceInfo=getMockedServiceModel(getClass().getResource("test-soap-header.wsdl").toString()); BindingInfo binding=serviceInfo.getBinding(new QName("http://org.apache.cxf/headers","headerTesterSOAPBinding")); BindingOperationInfo bop=binding.getOperation(new QName("http://org.apache.cxf/headers","inHeader")); soapMessage.getExchange().put(BindingOperationInfo.class,bop); soapMessage.getInterceptorChain().doIntercept(soapMessage); assertEquals("DummaySoapInterceptor getRoles has been called!",true,dsi.isCalledGetRoles()); assertEquals("DummaySoapInterceptor getUnderstood has been called!",true,dsi.isCalledGetUnderstood()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testHandleMessageWithSoapHeader12Param() throws Exception { prepareSoapMessage("test-soap-12-header.xml"); dsi.getUnderstoodHeaders().add(RESERVATION); ServiceInfo serviceInfo=getMockedServiceModel(getClass().getResource("test-soap-12-header.wsdl").toString()); BindingInfo binding=serviceInfo.getBinding(new QName("http://org.apache.cxf/headers","headerTesterSOAPBinding")); BindingOperationInfo bop=binding.getOperation(new QName("http://org.apache.cxf/headers","inHeader")); soapMessage.getExchange().put(BindingOperationInfo.class,bop); soapMessage.getInterceptorChain().doIntercept(soapMessage); assertEquals("DummaySoapInterceptor getRoles has been called!",true,dsi.isCalledGetRoles()); assertEquals("DummaySoapInterceptor getUnderstood has been called!",true,dsi.isCalledGetUnderstood()); }

APIUtilityVerifier BranchVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testHandleMessageFail() throws Exception { prepareSoapMessage("test-soap-header.xml"); dsi.getUnderstoodHeaders().add(RESERVATION); soapMessage.getInterceptorChain().doIntercept(soapMessage); assertEquals("DummaySoapInterceptor getRoles has been called!",true,dsi.isCalledGetRoles()); assertEquals("DummaySoapInterceptor getUnderstood has been called!",true,dsi.isCalledGetUnderstood()); Set ie=CastUtils.cast((Set)soapMessage.get(MustUnderstandInterceptor.UNKNOWNS)); if (ie == null) { fail("InBound unknowns missing! Exception should be Can't understands QNames: " + PASSENGER); } else { assertTrue(ie.contains(PASSENGER)); } }

Class: org.apache.cxf.binding.soap.RPCInInterceptorTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testInterceptorRPCLitOutbound() throws Exception { RPCInInterceptor interceptor=new RPCInInterceptor(); soapMessage.setContent(XMLStreamReader.class,XMLInputFactory.newInstance().createXMLStreamReader(getTestStream(getClass(),"/rpc-resp.xml"))); soapMessage.put(Message.REQUESTOR_ROLE,Boolean.TRUE); interceptor.handleMessage(soapMessage); List parameters=soapMessage.getContent(List.class); assertEquals(1,parameters.size()); Object obj=parameters.get(0); assertTrue(obj instanceof MyComplexStruct); MyComplexStruct s=(MyComplexStruct)obj; assertEquals("elem1",s.getElem1()); assertEquals("elem2",s.getElem2()); assertEquals(45,s.getElem3()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testInterceptorRPCLitInbound() throws Exception { RPCInInterceptor interceptor=new RPCInInterceptor(); soapMessage.setContent(XMLStreamReader.class,XMLInputFactory.newInstance().createXMLStreamReader(getTestStream(getClass(),"/rpc-req.xml"))); interceptor.handleMessage(soapMessage); List parameters=soapMessage.getContent(List.class); assertEquals(2,parameters.size()); Object obj=parameters.get(1); assertTrue(obj instanceof MyComplexStruct); MyComplexStruct s=(MyComplexStruct)obj; assertEquals("elem1",s.getElem1()); assertEquals("elem2",s.getElem2()); assertEquals(45,s.getElem3()); }

Class: org.apache.cxf.binding.soap.RPCOutInterceptorTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testWriteInbound() throws Exception { RPCOutInterceptor interceptor=new RPCOutInterceptor(); soapMessage.setContent(XMLStreamWriter.class,XMLOutputFactory.newInstance().createXMLStreamWriter(baos)); interceptor.handleMessage(soapMessage); assertNull(soapMessage.getContent(Exception.class)); soapMessage.getContent(XMLStreamWriter.class).flush(); baos.flush(); ByteArrayInputStream bais=new ByteArrayInputStream(baos.toByteArray()); XMLStreamReader xr=StaxUtils.createXMLStreamReader(bais); DepthXMLStreamReader reader=new DepthXMLStreamReader(xr); StaxUtils.toNextElement(reader); assertEquals(new QName("http://apache.org/hello_world_rpclit","sendReceiveDataResponse"),reader.getName()); StaxUtils.nextEvent(reader); StaxUtils.toNextElement(reader); assertEquals(new QName(null,"out"),reader.getName()); StaxUtils.nextEvent(reader); StaxUtils.toNextElement(reader); assertEquals(new QName("http://apache.org/hello_world_rpclit/types","elem1"),reader.getName()); StaxUtils.nextEvent(reader); StaxUtils.toNextText(reader); assertEquals("elem1",reader.getText()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testWriteOutbound() throws Exception { RPCOutInterceptor interceptor=new RPCOutInterceptor(); soapMessage.setContent(XMLStreamWriter.class,XMLOutputFactory.newInstance().createXMLStreamWriter(baos)); soapMessage.put(Message.REQUESTOR_ROLE,Boolean.TRUE); interceptor.handleMessage(soapMessage); assertNull(soapMessage.getContent(Exception.class)); soapMessage.getContent(XMLStreamWriter.class).flush(); baos.flush(); ByteArrayInputStream bais=new ByteArrayInputStream(baos.toByteArray()); XMLStreamReader xr=StaxUtils.createXMLStreamReader(bais); DepthXMLStreamReader reader=new DepthXMLStreamReader(xr); StaxUtils.toNextElement(reader); assertEquals(new QName("http://apache.org/hello_world_rpclit","sendReceiveData"),reader.getName()); StaxUtils.nextEvent(reader); StaxUtils.toNextElement(reader); assertEquals(new QName(null,"in"),reader.getName()); StaxUtils.toNextText(reader); assertEquals("elem1",reader.getText()); }

Class: org.apache.cxf.binding.soap.ReadHeaderInterceptorTest

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testBadHttpVerb() throws Exception { prepareSoapMessage("test-soap-header.xml"); soapMessage.put(Message.HTTP_REQUEST_METHOD,"OPTIONS"); ReadHeadersInterceptor r=new ReadHeadersInterceptor(BusFactory.getDefaultBus()); try { r.handleMessage(soapMessage); fail("Did not throw exception"); } catch ( Fault f) { assertEquals(405,f.getStatusCode()); } }

APIUtilityVerifier IterativeVerifier BranchVerifier UtilityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testHandleHeader(){ try { prepareSoapMessage("test-soap-header.xml"); } catch ( IOException ioe) { fail("Failed in creating soap message"); } staxIntc.handleMessage(soapMessage); soapMessage.getInterceptorChain().doIntercept(soapMessage); XMLStreamReader xmlReader=soapMessage.getContent(XMLStreamReader.class); assertEquals("check the first entry of body","itinerary",xmlReader.getLocalName()); List
eleHeaders=soapMessage.getHeaders(); List headerChilds=new ArrayList(); Iterator
iter=eleHeaders.iterator(); while (iter.hasNext()) { Header hdr=iter.next(); if (hdr.getObject() instanceof Element) { headerChilds.add((Element)hdr.getObject()); } } assertEquals(2,headerChilds.size()); for (int i=0; i < headerChilds.size(); i++) { Element ele=headerChilds.get(i); if (ele.getLocalName().equals("reservation")) { Element reservation=ele; List reservationChilds=new ArrayList(); Element elem=DOMUtils.getFirstElement(reservation); while (elem != null) { reservationChilds.add(elem); elem=DOMUtils.getNextElement(elem); } assertEquals(2,reservationChilds.size()); assertEquals("reference",reservationChilds.get(0).getLocalName()); assertEquals("uuid:093a2da1-q345-739r-ba5d-pqff98fe8j7d",reservationChilds.get(0).getTextContent()); assertEquals("dateAndTime",reservationChilds.get(1).getLocalName()); assertEquals("2001-11-29T13:20:00.000-05:00",reservationChilds.get(1).getTextContent()); } if (ele.getLocalName().equals("passenger")) { Element passenger=ele; assertNotNull(passenger); Element child=DOMUtils.getFirstElement(passenger); assertNotNull("passenger should have a child element",child); assertEquals("name",child.getLocalName()); assertEquals("Bob",child.getTextContent()); } } }

UtilityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBadSOAPEnvelopeNamespace() throws Exception { soapMessage=TestUtil.createEmptySoapMessage(Soap12.getInstance(),chain); InputStream in=getClass().getResourceAsStream("test-bad-env.xml"); assertNotNull(in); ByteArrayDataSource bads=new ByteArrayDataSource(in,"test/xml"); soapMessage.setContent(InputStream.class,bads.getInputStream()); ReadHeadersInterceptor r=new ReadHeadersInterceptor(BusFactory.getDefaultBus()); try { r.handleMessage(soapMessage); fail("Did not throw exception"); } catch ( SoapFault f) { assertEquals(Soap11.getInstance().getVersionMismatch(),f.getFaultCode()); } }

UtilityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBadSOAPEnvelopeName() throws Exception { soapMessage=TestUtil.createEmptySoapMessage(Soap12.getInstance(),chain); InputStream in=getClass().getResourceAsStream("test-bad-envname.xml"); assertNotNull(in); ByteArrayDataSource bads=new ByteArrayDataSource(in,"test/xml"); soapMessage.setContent(InputStream.class,bads.getInputStream()); ReadHeadersInterceptor r=new ReadHeadersInterceptor(BusFactory.getDefaultBus()); try { r.handleMessage(soapMessage); fail("Did not throw exception"); } catch ( SoapFault f) { assertEquals(Soap11.getInstance().getSender(),f.getFaultCode()); } }

Class: org.apache.cxf.binding.soap.ServiceModelUtilTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetSchema() throws Exception { BindingInfo bindingInfo=null; bindingInfo=serviceInfo.getBindings().iterator().next(); QName name=new QName(serviceInfo.getName().getNamespaceURI(),"inHeader"); BindingOperationInfo inHeader=bindingInfo.getOperation(name); BindingMessageInfo input=inHeader.getInput(); assertNotNull(input); assertEquals(input.getMessageInfo().getName().getLocalPart(),"inHeaderRequest"); assertEquals(input.getMessageInfo().getName().getNamespaceURI(),"http://org.apache.cxf/headers"); assertEquals(input.getMessageInfo().getMessageParts().size(),2); assertTrue(input.getMessageInfo().getMessageParts().get(0).isElement()); assertEquals(input.getMessageInfo().getMessageParts().get(0).getElementQName().getLocalPart(),"inHeader"); assertEquals(input.getMessageInfo().getMessageParts().get(0).getElementQName().getNamespaceURI(),"http://org.apache.cxf/headers"); assertTrue(input.getMessageInfo().getMessageParts().get(0).isElement()); assertEquals(input.getMessageInfo().getMessageParts().get(1).getElementQName().getLocalPart(),"passenger"); assertEquals(input.getMessageInfo().getMessageParts().get(1).getElementQName().getNamespaceURI(),"http://mycompany.example.com/employees"); assertTrue(input.getMessageInfo().getMessageParts().get(1).isElement()); MessagePartInfo messagePartInfo=input.getMessageInfo().getMessageParts().get(0); SchemaInfo schemaInfo=ServiceModelUtil.getSchema(serviceInfo,messagePartInfo); assertEquals(schemaInfo.getNamespaceURI(),"http://org.apache.cxf/headers"); messagePartInfo=input.getMessageInfo().getMessageParts().get(1); schemaInfo=ServiceModelUtil.getSchema(serviceInfo,messagePartInfo); assertEquals(schemaInfo.getNamespaceURI(),"http://mycompany.example.com/employees"); }

Class: org.apache.cxf.binding.soap.SoapActionInterceptorTest

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSoapAction() throws Exception { SoapPreProtocolOutInterceptor i=new SoapPreProtocolOutInterceptor(); Message message=new MessageImpl(); message.setExchange(new ExchangeImpl()); message.getExchange().setOutMessage(message); SoapBinding sb=new SoapBinding(null); message=sb.createMessage(message); assertNotNull(message); assertTrue(message instanceof SoapMessage); SoapMessage soapMessage=(SoapMessage)message; soapMessage.put(Message.REQUESTOR_ROLE,Boolean.TRUE); assertEquals(Soap11.getInstance(),soapMessage.getVersion()); (new SoapPreProtocolOutInterceptor()).handleMessage(soapMessage); Map> reqHeaders=CastUtils.cast((Map)soapMessage.get(Message.PROTOCOL_HEADERS)); assertNotNull(reqHeaders); assertEquals("\"\"",reqHeaders.get(SoapBindingConstants.SOAP_ACTION).get(0)); sb.setSoapVersion(Soap12.getInstance()); soapMessage.clear(); soapMessage=(SoapMessage)sb.createMessage(soapMessage); soapMessage.put(Message.REQUESTOR_ROLE,Boolean.TRUE); i.handleMessage(soapMessage); String ct=(String)soapMessage.get(Message.CONTENT_TYPE); assertEquals("application/soap+xml",ct); BindingOperationInfo bop=createBindingOperation(); soapMessage.getExchange().put(BindingOperationInfo.class,bop); SoapOperationInfo soapInfo=new SoapOperationInfo(); soapInfo.setAction("foo"); bop.addExtensor(soapInfo); i.handleMessage(soapMessage); ct=(String)soapMessage.get(Message.CONTENT_TYPE); assertEquals("application/soap+xml; action=\"foo\"",ct); }

Class: org.apache.cxf.binding.soap.SoapBindingFactoryTest

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testFactory() throws Exception { Definition d=createDefinition("/wsdl_soap/hello_world.wsdl"); Bus bus=getMockBus(); BindingFactoryManager bfm=getBindingFactoryManager(WSDLConstants.NS_SOAP11,bus); bus.getExtension(BindingFactoryManager.class); expectLastCall().andReturn(bfm).anyTimes(); DestinationFactoryManager dfm=control.createMock(DestinationFactoryManager.class); expect(bus.getExtension(DestinationFactoryManager.class)).andStubReturn(dfm); control.replay(); WSDLServiceBuilder builder=new WSDLServiceBuilder(bus); ServiceInfo serviceInfo=builder.buildServices(d,new QName("http://apache.org/hello_world_soap_http","SOAPService")).get(0); BindingInfo bi=serviceInfo.getBindings().iterator().next(); assertTrue(bi instanceof SoapBindingInfo); SoapBindingInfo sbi=(SoapBindingInfo)bi; assertEquals("document",sbi.getStyle()); assertTrue(WSDLConstants.NS_SOAP11_HTTP_TRANSPORT.equalsIgnoreCase(sbi.getTransportURI())); assertTrue(sbi.getSoapVersion() instanceof Soap11); BindingOperationInfo boi=sbi.getOperation(new QName("http://apache.org/hello_world_soap_http","sayHi")); SoapOperationInfo sboi=boi.getExtensor(SoapOperationInfo.class); assertNotNull(sboi); assertEquals("document",sboi.getStyle()); assertEquals("",sboi.getAction()); BindingMessageInfo input=boi.getInput(); SoapBodyInfo bodyInfo=input.getExtensor(SoapBodyInfo.class); assertEquals("literal",bodyInfo.getUse()); List parts=bodyInfo.getParts(); assertNotNull(parts); assertEquals(1,parts.size()); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSoap12Factory() throws Exception { Definition d=createDefinition("/wsdl_soap/hello_world_soap12.wsdl"); Bus bus=getMockBus(); BindingFactoryManager bfm=getBindingFactoryManager(WSDLConstants.NS_SOAP12,bus); expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bfm); DestinationFactoryManager dfm=control.createMock(DestinationFactoryManager.class); expect(bus.getExtension(DestinationFactoryManager.class)).andStubReturn(dfm); control.replay(); WSDLServiceBuilder builder=new WSDLServiceBuilder(bus); ServiceInfo serviceInfo=builder.buildServices(d,new QName("http://apache.org/hello_world_soap12_http","SOAPService")).get(0); BindingInfo bi=serviceInfo.getBindings().iterator().next(); assertTrue(bi instanceof SoapBindingInfo); SoapBindingInfo sbi=(SoapBindingInfo)bi; assertEquals("document",sbi.getStyle()); assertEquals(WSDLConstants.NS_SOAP_HTTP_TRANSPORT,sbi.getTransportURI()); assertTrue(sbi.getSoapVersion() instanceof Soap12); BindingOperationInfo boi=sbi.getOperation(new QName("http://apache.org/hello_world_soap12_http","sayHi")); SoapOperationInfo sboi=boi.getExtensor(SoapOperationInfo.class); assertNotNull(sboi); assertEquals("document",sboi.getStyle()); assertEquals("sayHiAction",sboi.getAction()); BindingMessageInfo input=boi.getInput(); SoapBodyInfo bodyInfo=input.getExtensor(SoapBodyInfo.class); assertEquals("literal",bodyInfo.getUse()); List parts=bodyInfo.getParts(); assertNotNull(parts); assertEquals(1,parts.size()); boi=sbi.getOperation(new QName("http://apache.org/hello_world_soap12_http","pingMe")); sboi=boi.getExtensor(SoapOperationInfo.class); assertNotNull(sboi); assertEquals("document",sboi.getStyle()); assertEquals("",sboi.getAction()); Collection faults=boi.getFaults(); assertEquals(1,faults.size()); BindingFaultInfo faultInfo=boi.getFault(new QName("http://apache.org/hello_world_soap12_http","pingMeFault")); assertNotNull(faultInfo); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testNoBodyParts() throws Exception { Definition d=createDefinition("/wsdl_soap/no_body_parts.wsdl"); Bus bus=getMockBus(); BindingFactoryManager bfm=getBindingFactoryManager(WSDLConstants.NS_SOAP11,bus); bus.getExtension(BindingFactoryManager.class); expectLastCall().andReturn(bfm).anyTimes(); DestinationFactoryManager dfm=control.createMock(DestinationFactoryManager.class); expect(bus.getExtension(DestinationFactoryManager.class)).andStubReturn(dfm); control.replay(); WSDLServiceBuilder builder=new WSDLServiceBuilder(bus); ServiceInfo serviceInfo=builder.buildServices(d,new QName("urn:org:apache:cxf:no_body_parts/wsdl","NoBodyParts")).get(0); BindingInfo bi=serviceInfo.getBindings().iterator().next(); assertTrue(bi instanceof SoapBindingInfo); SoapBindingInfo sbi=(SoapBindingInfo)bi; assertEquals("document",sbi.getStyle()); assertTrue(WSDLConstants.NS_SOAP11_HTTP_TRANSPORT.equalsIgnoreCase(sbi.getTransportURI())); assertTrue(sbi.getSoapVersion() instanceof Soap11); BindingOperationInfo boi=sbi.getOperation(new QName("urn:org:apache:cxf:no_body_parts/wsdl","operation1")); assertNotNull(boi); SoapOperationInfo sboi=boi.getExtensor(SoapOperationInfo.class); assertNotNull(sboi); assertNull(sboi.getStyle()); assertEquals("",sboi.getAction()); BindingMessageInfo input=boi.getInput(); SoapBodyInfo bodyInfo=input.getExtensor(SoapBodyInfo.class); assertNull(bodyInfo.getUse()); List parts=bodyInfo.getParts(); assertNotNull(parts); assertEquals(0,parts.size()); }

Class: org.apache.cxf.binding.soap.SoapBindingTest

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCreateMessage() throws Exception { Message message=new MessageImpl(); SoapBinding sb=new SoapBinding(null); message=sb.createMessage(message); assertNotNull(message); assertTrue(message instanceof SoapMessage); SoapMessage soapMessage=(SoapMessage)message; assertEquals(Soap11.getInstance(),soapMessage.getVersion()); assertEquals("text/xml",soapMessage.get(Message.CONTENT_TYPE)); soapMessage.remove(Message.CONTENT_TYPE); sb.setSoapVersion(Soap12.getInstance()); soapMessage=(SoapMessage)sb.createMessage(soapMessage); assertEquals(Soap12.getInstance(),soapMessage.getVersion()); assertEquals("application/soap+xml",soapMessage.get(Message.CONTENT_TYPE)); }

Class: org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptorTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAddNSContext() throws Exception { SoapMessage message=setUpMessage(); message.put("org.apache.cxf.binding.soap.addNamespaceContext","true"); interceptor.handleMessage(message); Map nsc=CastUtils.cast((Map)message.get("soap.body.ns.context")); assertNotNull(nsc); assertEquals("http://www.w3.org/2001/XMLSchema-instance",nsc.get("xsi")); assertEquals("http://www.w3.org/2001/XMLSchema",nsc.get("xs")); assertEquals("tmp:bar",nsc.get("bar")); }

Class: org.apache.cxf.binding.soap.interceptor.SoapActionInInterceptorTest

APIUtilityVerifier EqualityVerifier 
@Test public void testGetSoapActionForSOAP12() throws Exception { SoapMessage message=setUpMessage("application/soap+xml; action=\"urn:cxf\"",Soap12.getInstance(),null); control.replay(); String action=SoapActionInInterceptor.getSoapAction(message); assertEquals("urn:cxf",action); control.verify(); }

APIUtilityVerifier EqualityVerifier 
@Test public void testGetSoapActionForSOAP12SwAWithAction() throws Exception { SoapMessage message=setUpMessage("multipart/related; start-info=\"application/soap+xml\"; action=\"urn:cxf\"",Soap12.getInstance(),null); control.replay(); String action=SoapActionInInterceptor.getSoapAction(message); assertEquals("urn:cxf",action); control.verify(); }

APIUtilityVerifier EqualityVerifier 
@Test public void testGetSoapActionForSOAP12SwAWithStartInfo() throws Exception { SoapMessage message=setUpMessage("multipart/related; start-info=\"application/soap+xml; action=\\\"urn:cxf\\\"",Soap12.getInstance(),null); control.replay(); String action=SoapActionInInterceptor.getSoapAction(message); assertEquals("urn:cxf",action); control.verify(); }

APIUtilityVerifier EqualityVerifier 
@Test public void testGetSoapActionForSOAP12SwAWithActionInPartHeaders() throws Exception { SoapMessage message=setUpMessage("multipart/related",Soap12.getInstance(),"urn:cxf"); control.replay(); String action=SoapActionInInterceptor.getSoapAction(message); assertEquals("urn:cxf",action); control.verify(); }

APIUtilityVerifier EqualityVerifier 
@Test public void testGetSoapActionForSOAP11() throws Exception { SoapMessage message=setUpMessage("text/xml",Soap11.getInstance(),"urn:cxf"); control.replay(); String action=SoapActionInInterceptor.getSoapAction(message); assertEquals("urn:cxf",action); control.verify(); }

APIUtilityVerifier EqualityVerifier 
@Test public void testGetSoapActionForSOAP11MTOM() throws Exception { SoapMessage message=setUpMessage("multipart/related; type=\"application/xop+xml\"; start-info=\"text/xml\"",Soap11.getInstance(),"urn:cxf"); control.replay(); String action=SoapActionInInterceptor.getSoapAction(message); assertEquals("urn:cxf",action); control.verify(); }

APIUtilityVerifier EqualityVerifier 
@Test public void testGetSoapActionForSOAP11SwA() throws Exception { SoapMessage message=setUpMessage("multipart/related",Soap11.getInstance(),"urn:cxf"); control.replay(); String action=SoapActionInInterceptor.getSoapAction(message); assertEquals("urn:cxf",action); control.verify(); }

APIUtilityVerifier EqualityVerifier 
@Test public void testGetSoapActionForSOAP12MTOMWithAction() throws Exception { SoapMessage message=setUpMessage("multipart/related; type=\"application/xop+xml\"" + "; start-info=\"application/soap+xml\"; action=\"urn:cxf\"",Soap11.getInstance(),"urn:cxf"); control.replay(); String action=SoapActionInInterceptor.getSoapAction(message); assertEquals("urn:cxf",action); control.verify(); }

Class: org.apache.cxf.binding.soap.interceptor.SoapFaultSerializerTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCXF4181() throws Exception { SoapMessage m=new SoapMessage(new MessageImpl()); m.put(Message.HTTP_REQUEST_METHOD,"POST"); m.setVersion(Soap12.getInstance()); XMLStreamReader reader=StaxUtils.createXMLStreamReader(this.getClass().getResourceAsStream("cxf4181.xml")); m.setContent(XMLStreamReader.class,reader); new SAAJPreInInterceptor().handleMessage(m); new ReadHeadersInterceptor(null).handleMessage(m); new StartBodyInterceptor().handleMessage(m); new SAAJInInterceptor().handleMessage(m); new Soap12FaultInInterceptor().handleMessage(m); Node nd=m.getContent(Node.class); SOAPPart part=(SOAPPart)nd; assertEquals("S",part.getEnvelope().getPrefix()); assertEquals("S2",part.getEnvelope().getHeader().getPrefix()); assertEquals("S3",part.getEnvelope().getBody().getPrefix()); SOAPFault fault=part.getEnvelope().getBody().getFault(); assertEquals("S",fault.getPrefix()); assertEquals("Authentication Failure",fault.getFaultString()); SoapFault fault2=(SoapFault)m.getContent(Exception.class); assertNotNull(fault2); assertEquals(Soap12.getInstance().getSender(),fault2.getFaultCode()); assertEquals(new QName("http://schemas.xmlsoap.org/ws/2005/02/trust","FailedAuthentication"),fault2.getSubCode()); Element el=part.getEnvelope().getBody(); nd=el.getFirstChild(); int count=0; while (nd != null) { if (nd instanceof Element) { count++; } nd=nd.getNextSibling(); } assertEquals(1,count); m=new SoapMessage(new MessageImpl()); m.setVersion(Soap12.getInstance()); reader=StaxUtils.createXMLStreamReader(this.getClass().getResourceAsStream("cxf4181.xml")); m.setContent(XMLStreamReader.class,reader); m.put(Message.HTTP_REQUEST_METHOD,"POST"); new ReadHeadersInterceptor(null).handleMessage(m); new StartBodyInterceptor().handleMessage(m); new Soap12FaultInInterceptor().handleMessage(m); nd=m.getContent(Node.class); fault2=(SoapFault)m.getContent(Exception.class); assertNotNull(fault2); assertEquals(Soap12.getInstance().getSender(),fault2.getFaultCode()); assertEquals(new QName("http://schemas.xmlsoap.org/ws/2005/02/trust","FailedAuthentication"),fault2.getSubCode()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSoap12WithMultipleSubCodesOut() throws Exception { String faultString="Hadrian caused this Fault!"; SoapFault fault=new SoapFault(faultString,Soap12.getInstance().getSender()); fault.addSubCode(new QName("http://cxf.apache.org/soap/fault","invalidsoap","cxffaultcode")); fault.addSubCode(new QName("http://cxf.apache.org/soap/fault2","invalidsoap2","cxffaultcode2")); SoapMessage m=new SoapMessage(new MessageImpl()); m.setVersion(Soap12.getInstance()); m.setContent(Exception.class,fault); ByteArrayOutputStream out=new ByteArrayOutputStream(); XMLStreamWriter writer=StaxUtils.createXMLStreamWriter(out); writer.writeStartDocument(); writer.writeStartElement("Body"); m.setContent(XMLStreamWriter.class,writer); Soap12FaultOutInterceptorInternal.INSTANCE.handleMessage(m); writer.writeEndElement(); writer.writeEndDocument(); writer.close(); Document faultDoc=StaxUtils.read(new ByteArrayInputStream(out.toByteArray())); assertValid("//soap12env:Fault/soap12env:Code/soap12env:Value[text()='ns1:Sender']",faultDoc); assertValid("//soap12env:Fault/soap12env:Code/soap12env:Subcode/" + "soap12env:Value[text()='ns2:invalidsoap']",faultDoc); assertValid("//soap12env:Fault/soap12env:Code/soap12env:Subcode/soap12env:Subcode/" + "soap12env:Value[text()='ns2:invalidsoap2']",faultDoc); assertValid("//soap12env:Fault/soap12env:Reason/soap12env:Text[@xml:lang='en']",faultDoc); assertValid("//soap12env:Fault/soap12env:Reason/soap12env:Text[text()='" + faultString + "']",faultDoc); XMLStreamReader reader=StaxUtils.createXMLStreamReader(new ByteArrayInputStream(out.toByteArray())); m.setContent(XMLStreamReader.class,reader); reader.nextTag(); Soap12FaultInInterceptor inInterceptor=new Soap12FaultInInterceptor(); inInterceptor.handleMessage(m); SoapFault fault2=(SoapFault)m.getContent(Exception.class); assertNotNull(fault2); assertEquals(Soap12.getInstance().getSender(),fault2.getFaultCode()); assertEquals(fault.getMessage(),fault2.getMessage()); assertEquals(fault.getSubCodes(),fault2.getSubCodes()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSoap11Out() throws Exception { String faultString="Hadrian caused this Fault!"; SoapFault fault=new SoapFault(faultString,Soap11.getInstance().getSender()); SoapMessage m=new SoapMessage(new MessageImpl()); m.setExchange(new ExchangeImpl()); m.setContent(Exception.class,fault); ByteArrayOutputStream out=new ByteArrayOutputStream(); XMLStreamWriter writer=StaxUtils.createXMLStreamWriter(out); writer.writeStartDocument(); writer.writeStartElement("Body"); m.setContent(XMLStreamWriter.class,writer); Soap11FaultOutInterceptorInternal.INSTANCE.handleMessage(m); writer.writeEndElement(); writer.writeEndDocument(); writer.close(); Document faultDoc=StaxUtils.read(new ByteArrayInputStream(out.toByteArray())); assertValid("//s:Fault/faultcode[text()='ns1:Client']",faultDoc); assertValid("//s:Fault/faultstring[text()='" + faultString + "']",faultDoc); XMLStreamReader reader=StaxUtils.createXMLStreamReader(new ByteArrayInputStream(out.toByteArray())); m.setContent(XMLStreamReader.class,reader); reader.nextTag(); Soap11FaultInInterceptor inInterceptor=new Soap11FaultInInterceptor(); inInterceptor.handleMessage(m); SoapFault fault2=(SoapFault)m.getContent(Exception.class); assertNotNull(fault2); assertEquals(fault.getMessage(),fault2.getMessage()); assertEquals(Soap11.getInstance().getSender(),fault2.getFaultCode()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCXF1864() throws Exception { SoapMessage m=new SoapMessage(new MessageImpl()); m.setVersion(Soap12.getInstance()); XMLStreamReader reader=StaxUtils.createXMLStreamReader(this.getClass().getResourceAsStream("cxf1864.xml")); m.setContent(XMLStreamReader.class,reader); reader.nextTag(); Soap12FaultInInterceptor inInterceptor=new Soap12FaultInInterceptor(); inInterceptor.handleMessage(m); SoapFault fault2=(SoapFault)m.getContent(Exception.class); assertNotNull(fault2); assertEquals(Soap12.getInstance().getReceiver(),fault2.getFaultCode()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testFaultToSoapFault() throws Exception { Exception ex=new Exception(); Fault fault=new Fault(ex,Fault.FAULT_CODE_CLIENT); verifyFaultToSoapFault(fault,null,true,Soap11.getInstance()); verifyFaultToSoapFault(fault,null,true,Soap12.getInstance()); fault=new Fault(ex,Fault.FAULT_CODE_SERVER); verifyFaultToSoapFault(fault,null,false,Soap11.getInstance()); verifyFaultToSoapFault(fault,null,false,Soap12.getInstance()); fault.setMessage("fault-one"); verifyFaultToSoapFault(fault,"fault-one",false,Soap11.getInstance()); ex=new Exception("fault-two"); fault=new Fault(ex,Fault.FAULT_CODE_CLIENT); verifyFaultToSoapFault(fault,"fault-two",true,Soap11.getInstance()); fault=new Fault(ex,new QName("http://cxf.apache.org","myFaultCode")); SoapFault f=verifyFaultToSoapFault(fault,"fault-two",false,Soap12.getInstance()); assertEquals("myFaultCode",f.getSubCodes().get(0).getLocalPart()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCXF5493() throws Exception { SoapMessage m=new SoapMessage(new MessageImpl()); m.setVersion(Soap11.getInstance()); XMLStreamReader reader=StaxUtils.createXMLStreamReader(this.getClass().getResourceAsStream("cxf5493.xml")); m.setContent(XMLStreamReader.class,reader); reader.nextTag(); reader.nextTag(); reader.nextTag(); Soap11FaultInInterceptor inInterceptor=new Soap11FaultInInterceptor(); inInterceptor.handleMessage(m); SoapFault fault2=(SoapFault)m.getContent(Exception.class); assertNotNull(fault2); assertEquals(Soap11.getInstance().getReceiver(),fault2.getFaultCode()); assertEquals("some text containing a xml tag ",fault2.getMessage()); m=new SoapMessage(new MessageImpl()); m.put(Message.HTTP_REQUEST_METHOD,"POST"); m.setVersion(Soap11.getInstance()); reader=StaxUtils.createXMLStreamReader(this.getClass().getResourceAsStream("cxf5493.xml")); m.setContent(XMLStreamReader.class,reader); new SAAJPreInInterceptor().handleMessage(m); new ReadHeadersInterceptor(null).handleMessage(m); new StartBodyInterceptor().handleMessage(m); new SAAJInInterceptor().handleMessage(m); new Soap11FaultInInterceptor().handleMessage(m); fault2=(SoapFault)m.getContent(Exception.class); assertNotNull(fault2); assertEquals(Soap11.getInstance().getReceiver(),fault2.getFaultCode()); assertEquals("some text containing a xml tag ",fault2.getMessage()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSoap12Out() throws Exception { String faultString="Hadrian caused this Fault!"; SoapFault fault=new SoapFault(faultString,Soap12.getInstance().getSender()); QName qname=new QName("http://cxf.apache.org/soap/fault","invalidsoap","cxffaultcode"); fault.setSubCode(qname); SoapMessage m=new SoapMessage(new MessageImpl()); m.setVersion(Soap12.getInstance()); m.setContent(Exception.class,fault); ByteArrayOutputStream out=new ByteArrayOutputStream(); XMLStreamWriter writer=StaxUtils.createXMLStreamWriter(out); writer.writeStartDocument(); writer.writeStartElement("Body"); m.setContent(XMLStreamWriter.class,writer); Soap12FaultOutInterceptorInternal.INSTANCE.handleMessage(m); writer.writeEndElement(); writer.writeEndDocument(); writer.close(); Document faultDoc=StaxUtils.read(new ByteArrayInputStream(out.toByteArray())); assertValid("//soap12env:Fault/soap12env:Code/soap12env:Value[text()='ns1:Sender']",faultDoc); assertValid("//soap12env:Fault/soap12env:Code/soap12env:Subcode/" + "soap12env:Value[text()='ns2:invalidsoap']",faultDoc); assertValid("//soap12env:Fault/soap12env:Reason/soap12env:Text[@xml:lang='en']",faultDoc); assertValid("//soap12env:Fault/soap12env:Reason/soap12env:Text[text()='" + faultString + "']",faultDoc); XMLStreamReader reader=StaxUtils.createXMLStreamReader(new ByteArrayInputStream(out.toByteArray())); m.setContent(XMLStreamReader.class,reader); reader.nextTag(); Soap12FaultInInterceptor inInterceptor=new Soap12FaultInInterceptor(); inInterceptor.handleMessage(m); SoapFault fault2=(SoapFault)m.getContent(Exception.class); assertNotNull(fault2); assertEquals(Soap12.getInstance().getSender(),fault2.getFaultCode()); assertEquals(fault.getMessage(),fault2.getMessage()); assertEquals(fault.getSubCode(),fault2.getSubCode()); }

Class: org.apache.cxf.binding.soap.interceptor.SoapPreProtocolOutInterceptorTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testRequestorOutboundSoapAction() throws Exception { SoapMessage message=setUpMessage(); interceptor.handleMessage(message); control.verify(); Map> reqHeaders=CastUtils.cast((Map)message.get(Message.PROTOCOL_HEADERS)); assertNotNull(reqHeaders); List soapaction=reqHeaders.get("soapaction"); assertTrue(null != soapaction && soapaction.size() == 1); assertEquals("\"http://foo/bar/SEI/opReq\"",soapaction.get(0)); }

Class: org.apache.cxf.binding.soap.jms.interceptor.SoapFaultFactoryTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void createSoap12Fault(){ SoapBinding sb=control.createMock(SoapBinding.class); EasyMock.expect(sb.getSoapVersion()).andReturn(Soap12.getInstance()); setupJMSFault(true,SoapJMSConstants.getMismatchedSoapActionQName(),null,true); control.replay(); SoapFaultFactory factory=new SoapFaultFactory(sb); SoapFault fault=(SoapFault)factory.createFault(jmsFault); assertEquals("reason",fault.getReason()); assertEquals(Soap12.getInstance().getSender(),fault.getFaultCode()); assertEquals(SoapJMSConstants.getMismatchedSoapActionQName(),fault.getSubCode()); assertNull(fault.getDetail()); assertNull(fault.getCause()); control.verify(); }

InternalCallVerifier IdentityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void createSoap11Fault(){ SoapBinding sb=control.createMock(SoapBinding.class); EasyMock.expect(sb.getSoapVersion()).andReturn(Soap11.getInstance()); setupJMSFault(true,SoapJMSConstants.getContentTypeMismatchQName(),null,false); control.replay(); SoapFaultFactory factory=new SoapFaultFactory(sb); SoapFault fault=(SoapFault)factory.createFault(jmsFault); assertEquals("reason",fault.getReason()); assertEquals(SoapJMSConstants.getContentTypeMismatchQName(),fault.getFaultCode()); assertNull(fault.getDetail()); assertSame(jmsFault,fault.getCause()); control.verify(); }

Class: org.apache.cxf.binding.soap.saaj.SAAJInInterceptorTest

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testHandleHeader(){ try { prepareSoapMessage("../test-soap-header.xml"); } catch ( IOException ioe) { fail("Failed in creating soap message"); } staxIntc.handleMessage(soapMessage); rhi.handleMessage(soapMessage); sbi.handleMessage(soapMessage); saajIntc.handleMessage(soapMessage); XMLStreamReader xmlReader=soapMessage.getContent(XMLStreamReader.class); assertEquals("check the first entry of body","itinerary",xmlReader.getLocalName()); List
eleHeaders=soapMessage.getHeaders(); List headerChilds=new ArrayList(); Iterator
iter=eleHeaders.iterator(); while (iter.hasNext()) { Header hdr=iter.next(); if (hdr.getObject() instanceof Element) { headerChilds.add((Element)hdr.getObject()); } } assertEquals(2,headerChilds.size()); }

APIUtilityVerifier UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testFaultDetail() throws Exception { try { prepareSoapMessage("../test-soap-fault-detail.xml"); } catch ( IOException ioe) { fail("Failed in creating soap message"); } staxIntc.handleMessage(soapMessage); rhi.handleMessage(soapMessage); sbi.handleMessage(soapMessage); XMLStreamReader xmlReader=soapMessage.getContent(XMLStreamReader.class); xmlReader.nextTag(); saajIntc.handleMessage(soapMessage); SOAPMessage parsedMessage=soapMessage.getContent(SOAPMessage.class); SOAPFault fault=parsedMessage.getSOAPBody().getFault(); assertEquals("soap:Server",fault.getFaultCode()); assertEquals("This is a fault string",fault.getFaultString()); Detail faultDetail=fault.getDetail(); int count=0; Node nd=faultDetail.getFirstChild(); while (nd != null) { if (nd instanceof Element) { count++; } nd=nd.getNextSibling(); } assertEquals(2,count); Iterator detailEntries=faultDetail.getDetailEntries(); DetailEntry detailEntry=(DetailEntry)detailEntries.next(); assertEquals("errorcode",detailEntry.getLocalName()); assertEquals(3,Integer.valueOf(detailEntry.getTextContent()).intValue()); detailEntry=(DetailEntry)detailEntries.next(); assertEquals("errorstring",detailEntry.getLocalName()); assertEquals("This is a fault detail error string",detailEntry.getTextContent()); }

APIUtilityVerifier UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testFaultDetailSOAP12() throws Exception { try { prepareSoapMessage("../test-soap-12-fault-detail.xml"); } catch ( IOException ioe) { fail("Failed in creating soap message"); } staxIntc.handleMessage(soapMessage); rhi.handleMessage(soapMessage); sbi.handleMessage(soapMessage); XMLStreamReader xmlReader=soapMessage.getContent(XMLStreamReader.class); xmlReader.nextTag(); saajIntc.handleMessage(soapMessage); SOAPMessage parsedMessage=soapMessage.getContent(SOAPMessage.class); SOAPFault fault=parsedMessage.getSOAPBody().getFault(); assertEquals("Simulated failure",fault.getFaultReasonTexts().next()); assertEquals("soap:Receiver",fault.getFaultCode()); }

Class: org.apache.cxf.binding.xml.interceptor.XMLFaultOutInterceptorTest

InternalCallVerifier EqualityVerifier 
@Test public void testFault() throws Exception { FaultDetail detail=new FaultDetail(); detail.setMajor((short)2); detail.setMinor((short)1); PingMeFault fault=new PingMeFault("TEST_FAULT",detail); XMLFault xmlFault=XMLFault.createFault(new Fault(fault)); Element el=xmlFault.getOrCreateDetail(); JAXBContext ctx=JAXBContext.newInstance(FaultDetail.class); Marshaller m=ctx.createMarshaller(); m.marshal(detail,el); OutputStream outputStream=new ByteArrayOutputStream(); xmlMessage.setContent(OutputStream.class,outputStream); XMLStreamWriter writer=StaxUtils.createXMLStreamWriter(outputStream); xmlMessage.setContent(XMLStreamWriter.class,writer); xmlMessage.setContent(Exception.class,xmlFault); out.handleMessage(xmlMessage); outputStream.flush(); XMLStreamReader reader=getXMLReader(); DepthXMLStreamReader dxr=new DepthXMLStreamReader(reader); dxr.nextTag(); StaxUtils.toNextElement(dxr); assertEquals(XMLConstants.NS_XML_FORMAT,dxr.getNamespaceURI()); assertEquals(XMLFault.XML_FAULT_ROOT,dxr.getLocalName()); dxr.nextTag(); StaxUtils.toNextElement(dxr); assertEquals(XMLFault.XML_FAULT_STRING,dxr.getLocalName()); assertEquals(fault.toString(),dxr.getElementText()); dxr.nextTag(); StaxUtils.toNextElement(dxr); assertEquals(XMLFault.XML_FAULT_DETAIL,dxr.getLocalName()); dxr.nextTag(); StaxUtils.toNextElement(dxr); assertEquals("faultDetail",dxr.getLocalName()); }

Class: org.apache.cxf.binding.xml.interceptor.XMLMessageInInterceptorTest

EqualityVerifier NullVerifier HybridVerifier 
@Test public void testHandleMessageWrapped() throws Exception { String ns="http://apache.org/hello_world_xml_http/wrapped"; prepareMessage("/message-wrap.xml"); common("/wsdl/hello_world_xml_wrapped.wsdl",new QName(ns,"XMLPort"),GreetMe.class); OperationInfo op=serviceInfo.getInterface().getOperation(new QName(ns,"greetMe")); op.getInput().getMessagePartByIndex(0).setTypeClass(GreetMe.class); in.handleMessage(xmlMessage); docLitIn.handleMessage(xmlMessage); List list=xmlMessage.getContent(List.class); assertNotNull(list); assertEquals("expect 1 param",1,list.size()); assertEquals("method input me is String tli",true,list.get(0) instanceof GreetMe); }

EqualityVerifier NullVerifier HybridVerifier 
@Test public void testHandleMessageOnBareMultiParam() throws Exception { String ns="http://apache.org/hello_world_xml_http/bare"; prepareMessage("/message-bare-multi-param.xml"); common("/wsdl/hello_world_xml_bare.wsdl",new QName(ns,"XMLPort"),MyComplexStructType.class); OperationInfo op=serviceInfo.getInterface().getOperation(new QName(ns,"testMultiParamPart")); op.getInput().getMessagePartByIndex(0).setTypeClass(String.class); op.getInput().getMessagePartByIndex(1).setTypeClass(MyComplexStructType.class); in.handleMessage(xmlMessage); docLitIn.handleMessage(xmlMessage); List list=xmlMessage.getContent(List.class); assertNotNull(list); assertEquals("expect 2 param",2,list.size()); assertEquals("method input in2 is MyComplexStructType",true,list.get(1) instanceof MyComplexStructType); assertEquals("method input in1 is String tli",true,((String)list.get(0)).indexOf("tli") >= 0); }

EqualityVerifier NullVerifier HybridVerifier 
@Test public void testHandleMessageOnBareSingleChild() throws Exception { String ns="http://apache.org/hello_world_xml_http/bare"; prepareMessage("/message-bare-single-param-element.xml"); common("/wsdl/hello_world_xml_bare.wsdl",new QName(ns,"XMLPort")); OperationInfo op=serviceInfo.getInterface().getOperation(new QName(ns,"greetMe")); op.getInput().getMessagePartByIndex(0).setTypeClass(String.class); in.handleMessage(xmlMessage); docLitIn.handleMessage(xmlMessage); List list=xmlMessage.getContent(List.class); assertNotNull(list); assertEquals("expect 1 param",1,list.size()); assertEquals("method input me is String tli",true,((String)list.get(0)).indexOf("tli") >= 0); }

Class: org.apache.cxf.binding.xml.interceptor.XMLMessageOutInterceptorTest

BranchVerifier InternalCallVerifier EqualityVerifier 
@Test public void testBareOutMultiWithRoot() throws Exception { MyComplexStructType myComplexStruct=new MyComplexStructType(); myComplexStruct.setElem1("elem1"); myComplexStruct.setElem2("elem2"); myComplexStruct.setElem3(45); params.add("tli"); params.add(myComplexStruct); common("/wsdl/hello_world_xml_bare.wsdl",new QName(bareNs,"XMLPort"),MyComplexStructType.class); BindingInfo bi=super.serviceInfo.getBinding(new QName(bareNs,"Greeter_XMLBinding")); BindingOperationInfo boi=bi.getOperation(new QName(bareNs,"testMultiParamPart")); xmlMessage.getExchange().put(BindingOperationInfo.class,boi); out.handleMessage(xmlMessage); XMLStreamReader reader=getXMLReader(); DepthXMLStreamReader dxr=new DepthXMLStreamReader(reader); StaxUtils.nextEvent(dxr); StaxUtils.toNextElement(dxr); assertEquals(bareNs,dxr.getNamespaceURI()); assertEquals("multiParamRootReq",dxr.getLocalName()); StaxUtils.nextEvent(dxr); StaxUtils.toNextElement(dxr); assertEquals(bareRequestTypeQName,dxr.getName()); StaxUtils.nextEvent(dxr); if (StaxUtils.toNextText(dxr)) { assertEquals("tli",dxr.getText()); } boolean foundRequest=false; while (true) { StaxUtils.nextEvent(dxr); StaxUtils.toNextElement(dxr); QName requestType=new QName(dxr.getNamespaceURI(),dxr.getLocalName()); if (requestType.equals(bareMyComplexStructQName)) { foundRequest=true; break; } } assertEquals("found request type",true,foundRequest); }

InternalCallVerifier EqualityVerifier 
@Test public void testBareOutSingle() throws Exception { MyComplexStructType myComplexStruct=new MyComplexStructType(); myComplexStruct.setElem1("elem1"); myComplexStruct.setElem2("elem2"); myComplexStruct.setElem3(45); params.add(myComplexStruct); common("/wsdl/hello_world_xml_bare.wsdl",new QName(bareNs,"XMLPort"),MyComplexStructType.class); BindingInfo bi=super.serviceInfo.getBinding(new QName(bareNs,"Greeter_XMLBinding")); BindingOperationInfo boi=bi.getOperation(new QName(bareNs,"sendReceiveData")); xmlMessage.getExchange().put(BindingOperationInfo.class,boi); out.handleMessage(xmlMessage); XMLStreamReader reader=getXMLReader(); DepthXMLStreamReader dxr=new DepthXMLStreamReader(reader); StaxUtils.nextEvent(dxr); StaxUtils.toNextElement(dxr); assertEquals(bareMyComplexStructTypeQName.getLocalPart(),dxr.getLocalName()); StaxUtils.toNextElement(dxr); StaxUtils.toNextText(dxr); assertEquals(myComplexStruct.getElem1(),dxr.getText()); }

InternalCallVerifier EqualityVerifier 
@Test public void testWrapOut() throws Exception { GreetMe greetMe=new GreetMe(); greetMe.setRequestType("tli"); params.add(greetMe); common("/wsdl/hello_world_xml_wrapped.wsdl",new QName(wrapNs,"XMLPort"),GreetMe.class); BindingInfo bi=super.serviceInfo.getBinding(new QName(wrapNs,"Greeter_XMLBinding")); BindingOperationInfo boi=bi.getOperation(new QName(wrapNs,"greetMe")); xmlMessage.getExchange().put(BindingOperationInfo.class,boi); out.handleMessage(xmlMessage); XMLStreamReader reader=getXMLReader(); DepthXMLStreamReader dxr=new DepthXMLStreamReader(reader); StaxUtils.nextEvent(dxr); StaxUtils.toNextElement(dxr); assertEquals(wrapGreetMeQName.getNamespaceURI(),dxr.getNamespaceURI()); assertEquals(wrapGreetMeQName.getLocalPart(),dxr.getLocalName()); StaxUtils.toNextElement(dxr); StaxUtils.toNextText(dxr); assertEquals(greetMe.getRequestType(),dxr.getText()); }

Class: org.apache.cxf.bus.CXFBusImplTest

InternalCallVerifier EqualityVerifier 
@Test public void testBusID(){ Bus bus=new ExtensionManagerBus(); String id=bus.getId(); assertEquals("The bus id should be cxf",id,Bus.DEFAULT_BUS_ID + Math.abs(bus.hashCode())); bus.setId("test"); assertEquals("The bus id should be changed","test",bus.getId()); bus.shutdown(true); }

Class: org.apache.cxf.bus.extension.ExtensionTest

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testMutators(){ Extension e=new Extension(); String className="org.apache.cxf.bindings.soap.SoapBinding"; e.setClassname(className); assertEquals("Unexpected class name.",className,e.getClassname()); assertNull("Unexpected interface name.",e.getInterfaceName()); String interfaceName="org.apache.cxf.bindings.Binding"; e.setInterfaceName(interfaceName); assertEquals("Unexpected interface name.",interfaceName,e.getInterfaceName()); assertTrue("Extension is deferred.",!e.isDeferred()); e.setDeferred(true); assertTrue("Extension is not deferred.",e.isDeferred()); assertEquals("Unexpected size of namespace list.",0,e.getNamespaces().size()); }

Class: org.apache.cxf.bus.extension.TextExtensionFragmentParserTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetExtensions() throws IOException { InputStream is=TextExtensionFragmentParserTest.class.getResourceAsStream("extension2.txt"); List extensions=new TextExtensionFragmentParser(null).getExtensions(is); assertEquals("Unexpected number of Extension elements.",3,extensions.size()); Extension e=extensions.get(0); assertTrue("Extension is deferred.",!e.isDeferred()); assertEquals("Unexpected class name.","org.apache.cxf.foo.FooImpl",e.getClassname()); assertEquals("Unexpected number of namespace elements.",0,e.getNamespaces().size()); e=extensions.get(1); assertTrue("Extension is not deferred.",e.isDeferred()); assertEquals("Unexpected implementation class name.","java.lang.Boolean",e.getClassname()); assertNull("Interface should be null",e.getInterfaceName()); assertEquals("Unexpected number of namespace elements.",0,e.getNamespaces().size()); }

Class: org.apache.cxf.bus.managers.EndpointResolverRegistryImplTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testRegister(){ assertEquals("unexpected resolver count",0,registry.getResolvers().size()); registry.register(resolver1); assertEquals("unexpected resolver count",1,registry.getResolvers().size()); assertTrue("expected resolver to be registered",registry.getResolvers().contains(resolver1)); registry.unregister(resolver1); assertEquals("unexpected resolver count",0,registry.getResolvers().size()); assertFalse("expected resolver to be registered",registry.getResolvers().contains(resolver1)); registry.register(resolver2); registry.register(resolver1); assertEquals("unexpected resolver count",2,registry.getResolvers().size()); assertTrue("expected resolver to be registered",registry.getResolvers().contains(resolver1)); assertTrue("expected resolver to be registered",registry.getResolvers().contains(resolver2)); registry.unregister(resolver2); assertEquals("unexpected resolver count",1,registry.getResolvers().size()); assertTrue("expected resolver to be registered",registry.getResolvers().contains(resolver1)); assertFalse("expected resolver to be registered",registry.getResolvers().contains(resolver2)); }

Class: org.apache.cxf.bus.managers.ServerRegistryImpTest

InternalCallVerifier EqualityVerifier 
@Test public void testServerRegistryPreShutdown(){ ServerRegistryImpl serverRegistryImpl=new ServerRegistryImpl(); Server server=new DummyServer(serverRegistryImpl); server.start(); assertEquals("The serverList should have one service",serverRegistryImpl.serversList.size(),1); serverRegistryImpl.preShutdown(); assertEquals("The serverList should be clear ",serverRegistryImpl.serversList.size(),0); serverRegistryImpl.postShutdown(); assertEquals("The serverList should be clear ",serverRegistryImpl.serversList.size(),0); }

Class: org.apache.cxf.bus.managers.ServiceContractResolverRegistryImplTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testRegister(){ assertEquals("unexpected resolver count",0,registry.getResolvers().size()); registry.register(resolver1); assertEquals("unexpected resolver count",1,registry.getResolvers().size()); assertTrue("expected resolver to be registered",registry.getResolvers().contains(resolver1)); registry.unregister(resolver1); assertEquals("unexpected resolver count",0,registry.getResolvers().size()); assertFalse("expected resolver to be registered",registry.getResolvers().contains(resolver1)); registry.register(resolver2); registry.register(resolver1); assertEquals("unexpected resolver count",2,registry.getResolvers().size()); assertTrue("expected resolver to be registered",registry.getResolvers().contains(resolver1)); assertTrue("expected resolver to be registered",registry.getResolvers().contains(resolver2)); registry.unregister(resolver2); assertEquals("unexpected resolver count",1,registry.getResolvers().size()); assertTrue("expected resolver to be registered",registry.getResolvers().contains(resolver1)); assertFalse("expected resolver to be registered",registry.getResolvers().contains(resolver2)); }

Class: org.apache.cxf.bus.osgi.OSGiBusListenerTest

EqualityVerifier 
@Test public void testRegistratioWithServicesExcludesAndRestricted() throws Exception { setUpClientLifeCycleListeners(SERVICE_BUNDLE_NAMES,new String[]{RESTRICTED,null},EXCLUDES); setUpServerLifeCycleListeners(SERVICE_BUNDLE_NAMES,new String[]{RESTRICTED,null},EXCLUDES); Collection lst=new ArrayList(); setFeatures(SERVICE_BUNDLE_NAMES,new String[]{RESTRICTED,null},lst); EasyMock.expect(bus.getProperty("bus.extension.bundles.excludes")).andReturn(EXCLUDES); control.replay(); new OSGIBusListener(bus,new Object[]{bundleContext}); assertEquals(countServices(SERVICE_BUNDLE_NAMES,new String[]{RESTRICTED,null},EXCLUDES),lst.size()); control.verify(); }

EqualityVerifier 
@Test public void testRegistratioWithServices() throws Exception { setUpClientLifeCycleListeners(SERVICE_BUNDLE_NAMES,new String[]{null,null},null); setUpServerLifeCycleListeners(SERVICE_BUNDLE_NAMES,new String[]{null,null},null); Collection lst=new ArrayList(); setFeatures(SERVICE_BUNDLE_NAMES,new String[]{null,null},lst); control.replay(); new OSGIBusListener(bus,new Object[]{bundleContext}); assertEquals(countServices(SERVICE_BUNDLE_NAMES,new String[]{null,null},null),lst.size()); control.verify(); }

EqualityVerifier 
@Test public void testRegistratioWithServicesExcludes() throws Exception { setUpClientLifeCycleListeners(SERVICE_BUNDLE_NAMES,new String[]{null,null},EXCLUDES); setUpServerLifeCycleListeners(SERVICE_BUNDLE_NAMES,new String[]{null,null},EXCLUDES); Collection lst=new ArrayList(); setFeatures(SERVICE_BUNDLE_NAMES,new String[]{null,null},lst); EasyMock.expect(bus.getProperty("bus.extension.bundles.excludes")).andReturn(EXCLUDES); control.replay(); new OSGIBusListener(bus,new Object[]{bundleContext}); assertEquals(countServices(SERVICE_BUNDLE_NAMES,new String[]{null,null},EXCLUDES),lst.size()); control.verify(); }

Class: org.apache.cxf.bus.spring.BusApplicationContextTest

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testGetResources(){ BusApplicationContext ctx=null; try { ctx=new BusApplicationContext("nowhere.xml",false); fail("Bus creation should have thrown exception."); } catch ( BeansException bex) { } String cfgFile="/org/apache/cxf/bus/spring/resources/bus-overwrite.xml"; ctx=new BusApplicationContext(cfgFile,false); assertEquals("Unexpected number of resources",1,ctx.getConfigResources().length); ctx.close(); ctx=new BusApplicationContext(cfgFile,true); assertEquals("Unexpected number of resources",2,ctx.getConfigResources().length); ctx.close(); }

Class: org.apache.cxf.bus.spring.SpringBusFactoryTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDefault(){ Bus bus=new SpringBusFactory().createBus(); assertNotNull(bus); BindingFactoryManager bfm=bus.getExtension(BindingFactoryManager.class); assertNotNull("No binding factory manager",bfm); assertNotNull("No configurer",bus.getExtension(Configurer.class)); assertNotNull("No resource manager",bus.getExtension(ResourceManager.class)); assertNotNull("No destination factory manager",bus.getExtension(DestinationFactoryManager.class)); assertNotNull("No conduit initiator manager",bus.getExtension(ConduitInitiatorManager.class)); assertNotNull("No phase manager",bus.getExtension(PhaseManager.class)); assertNotNull("No workqueue manager",bus.getExtension(WorkQueueManager.class)); assertNotNull("No lifecycle manager",bus.getExtension(BusLifeCycleManager.class)); assertNotNull("No service registry",bus.getExtension(ServerRegistry.class)); try { bfm.getBindingFactory("http://cxf.apache.org/unknown"); } catch ( BusException ex) { } assertEquals("Unexpected interceptors",0,bus.getInInterceptors().size()); assertEquals("Unexpected interceptors",0,bus.getInFaultInterceptors().size()); assertEquals("Unexpected interceptors",0,bus.getOutInterceptors().size()); assertEquals("Unexpected interceptors",0,bus.getOutFaultInterceptors().size()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testPhases(){ Bus bus=new SpringBusFactory().createBus(); PhaseManager cxfPM=bus.getExtension(PhaseManager.class); PhaseManager defaultPM=new PhaseManagerImpl(); SortedSet cxfPhases=cxfPM.getInPhases(); SortedSet defaultPhases=defaultPM.getInPhases(); assertEquals(defaultPhases.size(),cxfPhases.size()); assertTrue(cxfPhases.equals(defaultPhases)); cxfPhases=cxfPM.getOutPhases(); defaultPhases=defaultPM.getOutPhases(); assertEquals(defaultPhases.size(),cxfPhases.size()); assertTrue(cxfPhases.equals(defaultPhases)); }

Class: org.apache.cxf.common.i18n.BundleUtilsTest

EqualityVerifier 
@Test public void testGetBundleName() throws Exception { assertEquals("unexpected resource bundle name","org.apache.cxf.common.i18n.Messages",BundleUtils.getBundleName(getClass())); assertEquals("unexpected resource bundle name","org.apache.cxf.common.i18n.Messages",BundleUtils.getBundleName(getClass(),"Messages")); }

EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetBundle() throws Exception { ResourceBundle bundle=BundleUtils.getBundle(getClass()); assertNotNull("expected resource bundle",bundle); assertEquals("unexpected resource","localized message",bundle.getString("I18N_MSG")); ResourceBundle nonDefaultBundle=BundleUtils.getBundle(getClass(),"Messages"); assertNotNull("expected resource bundle",nonDefaultBundle); assertEquals("unexpected resource","localized message",nonDefaultBundle.getString("I18N_MSG")); }

Class: org.apache.cxf.common.i18n.MessageTest

IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testMessageWithExplicitBundle() throws Exception { ResourceBundle bundle=BundleUtils.getBundle(getClass()); Message msg=new Message("SUB2_EXC",bundle,new Object[]{3,4}); assertSame("unexpected resource bundle",bundle,msg.bundle); assertEquals("unexpected message string","subbed in 4 & 3",msg.toString()); }

APIUtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testExceptionIO() throws java.lang.Exception { ResourceBundle bundle=BundleUtils.getBundle(getClass()); UncheckedException ex=new UncheckedException(new Message("SUB2_EXC",bundle,new Object[]{3,4})); ByteArrayOutputStream bout=new ByteArrayOutputStream(); ObjectOutputStream out=new ObjectOutputStream(bout); out.writeObject(ex); ByteArrayInputStream bin=new ByteArrayInputStream(bout.toByteArray()); ObjectInputStream in=new ObjectInputStream(bin); Object o=in.readObject(); assertTrue(o instanceof UncheckedException); UncheckedException ex2=(UncheckedException)o; assertEquals("subbed in 4 & 3",ex2.getMessage()); }

IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testMessageWithLoggerBundle() throws Exception { Message msg=new Message("SUB1_EXC",LOG,new Object[]{1}); assertSame("unexpected resource bundle",LOG.getResourceBundle(),msg.bundle); assertEquals("unexpected message string","subbed in 1 only",msg.toString()); }

Class: org.apache.cxf.common.logging.LogUtilsTest

EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetL7dLog() throws Exception { Logger log=LogUtils.getL7dLogger(LogUtilsTest.class,null,"testGetL7dLog"); assertNotNull("expected non-null logger",log); assertEquals("unexpected resource bundle name",BundleUtils.getBundleName(LogUtilsTest.class),log.getResourceBundleName()); Logger otherLogger=LogUtils.getL7dLogger(LogUtilsTest.class,"Messages","testGetL7dLog"); assertEquals("unexpected resource bundle name",BundleUtils.getBundleName(LogUtilsTest.class,"Messages"),otherLogger.getResourceBundleName()); }

EqualityVerifier PublicFieldVerifier 
@Test public void testClassMethodNames() throws Exception { Logger log=LogUtils.getL7dLogger(LogUtilsTest.class,null,"testClassMethodNames"); TestLogHandler handler=new TestLogHandler(); log.addHandler(handler); log.warning("hello"); String cname=handler.cname; String mname=handler.mname; LogUtils.log(log,Level.WARNING,"FOOBAR_MSG"); assertEquals(cname,handler.cname); assertEquals(mname,handler.mname); }

Class: org.apache.cxf.common.security.SimpleGroupTest

APIUtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testAddRemoveMembers(){ Group group=new SimpleGroup("group"); assertFalse(group.members().hasMoreElements()); group.addMember(new SimpleGroup("group","friend")); Enumeration members=group.members(); assertEquals(new SimpleGroup("group","friend"),members.nextElement()); assertFalse(members.hasMoreElements()); group.removeMember(new SimpleGroup("group","friend")); assertFalse(group.members().hasMoreElements()); }

EqualityVerifier 
@Test public void testName(){ assertEquals("group",new SimpleGroup("group","friend").getName()); assertEquals("group",new SimpleGroup("group",new SimplePrincipal("friend")).getName()); }

Class: org.apache.cxf.common.util.ASMHelperTest

APIUtilityVerifier EqualityVerifier 
@Test public void testEnumParamType() throws Exception { Method method=EnumTest.class.getMethod("test",new Class[]{EnumObject.class}); Type[] types=method.getGenericParameterTypes(); String classCode=ASMHelper.getClassCode(types[0]); assertEquals("Lorg/apache/cxf/common/util/ASMHelperTest$EnumObject;",classCode); }

Class: org.apache.cxf.common.util.Base64UtilityTest

APIUtilityVerifier EqualityVerifier 
@Test public void testEncodeDecodeStreams() throws Exception { byte bytes[]=new byte[100]; for (int x=0; x < bytes.length; x++) { bytes[x]=(byte)x; } ByteArrayOutputStream bout=new ByteArrayOutputStream(); ByteArrayOutputStream bout2=new ByteArrayOutputStream(); Base64Utility.encodeChunk(bytes,0,bytes.length,bout); String encodedString=IOUtils.newStringFromBytes(bout.toByteArray()); Base64Utility.decode(encodedString.toCharArray(),0,encodedString.length(),bout2); assertEquals(bytes,bout2.toByteArray()); String in="QWxhZGRpbjpvcGVuIHNlc2FtZQ=="; bout.reset(); bout2.reset(); Base64Utility.decode(in,bout); bytes=bout.toByteArray(); assertEquals("Aladdin:open sesame",IOUtils.newStringFromBytes(bytes)); StringWriter writer=new StringWriter(); Base64Utility.encode(bytes,0,bytes.length,writer); assertEquals(in,writer.toString()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testEncodeDecodeString() throws Exception { String in="QWxhZGRpbjpvcGVuIHNlc2FtZQ=="; byte bytes[]=Base64Utility.decode(in); assertEquals("Aladdin:open sesame",IOUtils.newStringFromBytes(bytes)); String encoded=Base64Utility.encode(bytes); assertEquals(in,encoded); }

APIUtilityVerifier EqualityVerifier 
@Test public void testEncodeAndStream() throws Exception { final String text="The true sign of intelligence is not knowledge but imagination."; ByteArrayOutputStream bos=new ByteArrayOutputStream(); byte[] bytes=text.getBytes(StandardCharsets.UTF_8); Base64Utility.encodeAndStream(bytes,0,bytes.length,bos); String decodedText=new String(Base64Utility.decode(bos.toString())); assertEquals(decodedText,text); }

APIUtilityVerifier EqualityVerifier PublicFieldVerifier 
@Test public void testEncodeMultipleChunks() throws Exception { final String text="The true sign of intelligence is not knowledge but imagination."; byte[] bytes=text.getBytes(StandardCharsets.UTF_8); assertEquals(63,bytes.length); String s1=new String(Base64Utility.encodeChunk(bytes,0,bytes.length)); StringBuilder sb=new StringBuilder(); int off=0; for (; off + 21 < bytes.length; off+=21) { sb.append(Base64Utility.encodeChunk(bytes,off,21)); } if (off < bytes.length) { sb.append(Base64Utility.encodeChunk(bytes,off,bytes.length - off)); } String s2=sb.toString(); assertEquals(s1,s2); }

APIUtilityVerifier EqualityVerifier NullVerifier PublicFieldVerifier HybridVerifier 
@Test public void testEncodeDecodeChunk() throws Exception { byte bytes[]=new byte[100]; for (int x=0; x < bytes.length; x++) { bytes[x]=(byte)x; } char encodedChars[]=Base64Utility.encodeChunk(bytes,0,-2); assertNull(encodedChars); encodedChars=Base64Utility.encodeChunk(bytes,0,bytes.length); assertNotNull(encodedChars); byte bytesDecoded[]=Base64Utility.decodeChunk(encodedChars,0,encodedChars.length); assertEquals(bytes,bytesDecoded); bytes=new byte[99]; for (int x=0; x < bytes.length; x++) { bytes[x]=(byte)x; } encodedChars=Base64Utility.encodeChunk(bytes,0,bytes.length); assertNotNull(encodedChars); bytesDecoded=Base64Utility.decodeChunk(encodedChars,0,encodedChars.length); assertEquals(bytes,bytesDecoded); bytes=new byte[98]; for (int x=0; x < bytes.length; x++) { bytes[x]=(byte)x; } encodedChars=Base64Utility.encodeChunk(bytes,0,bytes.length); assertNotNull(encodedChars); bytesDecoded=Base64Utility.decodeChunk(encodedChars,0,encodedChars.length); assertEquals(bytes,bytesDecoded); bytes=new byte[97]; for (int x=0; x < bytes.length; x++) { bytes[x]=(byte)x; } encodedChars=Base64Utility.encodeChunk(bytes,0,bytes.length); assertNotNull(encodedChars); bytesDecoded=Base64Utility.decodeChunk(encodedChars,0,encodedChars.length); assertEquals(bytes,bytesDecoded); bytesDecoded=Base64Utility.decodeChunk(new char[3],0,3); assertNull(bytesDecoded); }

Class: org.apache.cxf.common.util.PackageUtilsTest

EqualityVerifier 
@Test public void testgetPackageName() throws Exception { String packageName=PackageUtils.getPackageName(this.getClass()); assertEquals("Should get same packageName",this.getClass().getPackage().getName(),packageName); }

EqualityVerifier 
@Test public void testGetPackageName() throws Exception { String className="HelloWorld"; assertEquals("Should return empty string","",PackageUtils.getPackageName(className)); }

Class: org.apache.cxf.common.util.PropertiesLoaderUtilsTest

EqualityVerifier 
@Test public void testLoadBindings() throws Exception { assertEquals(soapBindingFactory,properties.getProperty("http://schemas.xmlsoap.org/wsdl/soap/")); assertEquals(soapBindingFactory,properties.getProperty("http://schemas.xmlsoap.org/wsdl/soap/http")); }

Class: org.apache.cxf.common.util.StringUtilsTest

EqualityVerifier 
@Test public void testDiff() throws Exception { String str1="http://local/SoapContext/SoapPort/greetMe/me/CXF"; String str2="http://local/SoapContext/SoapPort"; String str3="http://local/SoapContext/SoapPort/"; assertEquals("/greetMe/me/CXF",StringUtils.diff(str1,str2)); assertEquals("greetMe/me/CXF",StringUtils.diff(str1,str3)); assertEquals("http://local/SoapContext/SoapPort/",StringUtils.diff(str3,str1)); }

EqualityVerifier 
@Test public void testAddPortIfMissing() throws Exception { assertEquals("http://localhost:80",StringUtils.addDefaultPortIfMissing("http://localhost")); assertEquals("http://localhost:80/",StringUtils.addDefaultPortIfMissing("http://localhost/")); assertEquals("http://localhost:80/abc",StringUtils.addDefaultPortIfMissing("http://localhost/abc")); assertEquals("http://localhost:80",StringUtils.addDefaultPortIfMissing("http://localhost:80")); assertEquals("http://localhost:9090",StringUtils.addDefaultPortIfMissing("http://localhost","9090")); }

APIUtilityVerifier EqualityVerifier 
@Test public void testGetParts() throws Exception { String str="/greetMe/me/CXF"; List parts=StringUtils.getParts(str,"/"); assertEquals(3,parts.size()); assertEquals("greetMe",parts.get(0)); assertEquals("me",parts.get(1)); assertEquals("CXF",parts.get(2)); }

APIUtilityVerifier EqualityVerifier 
@Test public void testSplitWithDot() throws Exception { String str="a.b.c"; String[] parts=StringUtils.split(str,"\\.",-1); assertEquals(3,parts.length); assertEquals("a",parts[0]); assertEquals("b",parts[1]); assertEquals("c",parts[2]); }

EqualityVerifier 
@Test public void testGetFirstNotEmpty() throws Exception { assertEquals("greetMe",StringUtils.getFirstNotEmpty("/greetMe/me/CXF","/")); assertEquals("greetMe",StringUtils.getFirstNotEmpty("greetMe/me/CXF","/")); }

Class: org.apache.cxf.common.util.URIParserUtilsTest

EqualityVerifier NullVerifier HybridVerifier 
@Test public void testRelativize() throws URISyntaxException { assertNull(URIParserUtil.relativize(null,"foo")); assertNull(URIParserUtil.relativize("foo",null)); assertEquals("",URIParserUtil.relativize("","")); assertEquals("",URIParserUtil.relativize("fds","")); assertEquals("../",URIParserUtil.relativize("fds/","")); assertEquals("fdsfs",URIParserUtil.relativize("","fdsfs")); assertEquals("fdsfs/a",URIParserUtil.relativize("","fdsfs/a")); assertEquals("../de",URIParserUtil.relativize("ab/cd","de")); assertEquals("../de/fe/gh",URIParserUtil.relativize("ab/cd","de/fe/gh")); assertEquals("../../../de/fe/gh",URIParserUtil.relativize("/abc/def/","de/fe/gh")); assertNull(URIParserUtil.relativize("file:/c:/abc/def/","de/fe/gh")); assertEquals("pippo2.xsd",URIParserUtil.relativize("/abc/def/pippo1.xsd","/abc/def/pippo2.xsd")); assertEquals("../default/pippo2.xsd",URIParserUtil.relativize("/abc/def/pippo1.xsd","/abc/default/pippo2.xsd")); assertEquals("def/pippo2.xsd",URIParserUtil.relativize("/abc/def","/abc/def/pippo2.xsd")); assertEquals("hello_world_schema2.xsd",URIParserUtil.relativize("jar:file:/home/a.jar!/wsdl/others/","jar:file:/home/a.jar!/wsdl/others/hello_world_schema2.xsd")); }

Class: org.apache.cxf.common.util.UrlUtilsTest

EqualityVerifier 
@Test public void testUrlDecode(){ assertEquals("+ ",UrlUtils.urlDecode("%2B+")); }

EqualityVerifier 
@Test public void testUrlDecodeReserved(){ assertEquals("!$&'()*,;=",UrlUtils.urlDecode("!$&'()*,;=")); }

EqualityVerifier 
@Test public void testPathDecode(){ assertEquals("+++",UrlUtils.pathDecode("+%2B+")); }

APIUtilityVerifier EqualityVerifier 
@Test public void testUrlDecodeSingleCharMultipleEscapes(){ String s="ß"; String encoded=UrlUtils.urlEncode(s); assertEquals(s,UrlUtils.urlDecode(encoded)); }

Class: org.apache.cxf.common.util.XmlSchemaPrimitiveUtilsTest

EqualityVerifier 
@Test public void testXsdRepresentation(){ assertEquals("xsd:int",XmlSchemaPrimitiveUtils.getSchemaRepresentation(Integer.class,"xsd")); assertEquals("xsd:int",XmlSchemaPrimitiveUtils.getSchemaRepresentation(int.class,"xsd")); }

EqualityVerifier 
@Test public void testDefaultRepresentation(){ assertEquals("xs:int",XmlSchemaPrimitiveUtils.getSchemaRepresentation(Integer.class)); assertEquals("xs:int",XmlSchemaPrimitiveUtils.getSchemaRepresentation(int.class)); }

Class: org.apache.cxf.configuration.spring.ConfigurerImplTest

APIUtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testConfigureSimpleMatchingStarBeanId(){ SimpleBean sb=new SimpleBean("simple2"); BusApplicationContext ac=new BusApplicationContext("/org/apache/cxf/configuration/spring/test-beans.xml",false); ConfigurerImpl configurer=new ConfigurerImpl(); configurer.setApplicationContext(ac); configurer.configureBean(sb); assertTrue("Unexpected value for attribute booleanAttr",!sb.getBooleanAttr()); assertEquals("Unexpected value for attribute integerAttr",BigInteger.TEN,sb.getIntegerAttr()); assertEquals("Unexpected value for attribute stringAttr","StarHallo",sb.getStringAttr()); }

APIUtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testConfigureSimpleMatchingStarBeanIdWithChildInstance(){ SimpleBean sb=new ChildBean("simple2"); BusApplicationContext ac=new BusApplicationContext("/org/apache/cxf/configuration/spring/test-beans.xml",false); ConfigurerImpl configurer=new ConfigurerImpl(); configurer.setApplicationContext(ac); configurer.configureBean(sb); assertTrue("Unexpected value for attribute booleanAttr",!sb.getBooleanAttr()); assertEquals("Unexpected value for attribute integerAttr",BigInteger.TEN,sb.getIntegerAttr()); assertEquals("Unexpected value for attribute stringAttr","StarHallo",sb.getStringAttr()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testAddApplicationContext(){ ConfigurableApplicationContext context1=new ClassPathXmlApplicationContext("/org/apache/cxf/configuration/spring/test-beans.xml"); ConfigurerImpl configurer=new ConfigurerImpl(); configurer.setApplicationContext(context1); context1.close(); ConfigurableApplicationContext context2=new ClassPathXmlApplicationContext("/org/apache/cxf/configuration/spring/test-beans.xml"); configurer.addApplicationContext(context2); Set contexts=configurer.getAppContexts(); assertEquals("The Context's size is wrong",1,contexts.size()); assertTrue("The conetxts' contains a wrong application context",contexts.contains(context2)); }

APIUtilityVerifier IterativeVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testConfigureSimpleNoMatchingBean(){ SimpleBean sb=new SimpleBean("unknown"); BusApplicationContext ac=new BusApplicationContext("/org/apache/cxf/configuration/spring/test-beans.xml",false); ConfigurerImpl configurer=new ConfigurerImpl(ac); configurer.configureBean(sb); assertEquals("Unexpected value for attribute stringAttr","hello",sb.getStringAttr()); assertTrue("Unexpected value for attribute booleanAttr",sb.getBooleanAttr()); assertEquals("Unexpected value for attribute integerAttr",BigInteger.ONE,sb.getIntegerAttr()); assertEquals("Unexpected value for attribute intAttr",Integer.valueOf(2),sb.getIntAttr()); assertEquals("Unexpected value for attribute longAttr",Long.valueOf(3L),sb.getLongAttr()); assertEquals("Unexpected value for attribute shortAttr",Short.valueOf((short)4),sb.getShortAttr()); assertEquals("Unexpected value for attribute decimalAttr",new BigDecimal("5"),sb.getDecimalAttr()); assertEquals("Unexpected value for attribute floatAttr",new Float(6F),sb.getFloatAttr()); assertEquals("Unexpected value for attribute doubleAttr",Double.valueOf(7.0D),sb.getDoubleAttr()); assertEquals("Unexpected value for attribute byteAttr",Byte.valueOf((byte)8),sb.getByteAttr()); QName qn=sb.getQnameAttr(); assertEquals("Unexpected value for attribute qnameAttrNoDefault","schema",qn.getLocalPart()); assertEquals("Unexpected value for attribute qnameAttrNoDefault","http://www.w3.org/2001/XMLSchema",qn.getNamespaceURI()); byte[] expected=DatatypeConverter.parseBase64Binary("abcd"); byte[] val=sb.getBase64BinaryAttr(); assertEquals("Unexpected value for attribute base64BinaryAttrNoDefault",expected.length,val.length); for (int i=0; i < expected.length; i++) { assertEquals("Unexpected value for attribute base64BinaryAttrNoDefault",expected[i],val[i]); } expected=new HexBinaryAdapter().unmarshal("aaaa"); val=sb.getHexBinaryAttr(); assertEquals("Unexpected value for attribute hexBinaryAttrNoDefault",expected.length,val.length); for (int i=0; i < expected.length; i++) { assertEquals("Unexpected value for attribute hexBinaryAttrNoDefault",expected[i],val[i]); } assertEquals("Unexpected value for attribute unsignedIntAttrNoDefault",Long.valueOf(9L),sb.getUnsignedIntAttr()); assertEquals("Unexpected value for attribute unsignedShortAttrNoDefault",Integer.valueOf(10),sb.getUnsignedShortAttr()); assertEquals("Unexpected value for attribute unsignedByteAttrNoDefault",Short.valueOf((short)11),sb.getUnsignedByteAttr()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetBeanName(){ ConfigurerImpl configurer=new ConfigurerImpl(); Object beanInstance=new Configurable(){ public String getBeanName(){ return "a"; } } ; assertEquals("a",configurer.getBeanName(beanInstance)); final class NamedBean { @SuppressWarnings("unused") public String getBeanName(){ return "b"; } } beanInstance=new NamedBean(); assertEquals("b",configurer.getBeanName(beanInstance)); beanInstance=this; assertNull(configurer.getBeanName(beanInstance)); }

Class: org.apache.cxf.cxf1226.MissingQualification1226Test

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void lookForMissingNamespace() throws Exception { EndpointImpl endpoint=getBean(EndpointImpl.class,"helloWorld"); Document d=getWSDLDocument(endpoint.getServer()); NodeList schemas=assertValid("//xsd:schema[@targetNamespace='http://nstest.helloworld']",d); Element schemaElement=(Element)schemas.item(0); String ef=schemaElement.getAttribute("elementFormDefault"); assertEquals("qualified",ef); }

Class: org.apache.cxf.cxf1332.Cxf1332Test

EqualityVerifier 
@Test public void tryToSendStringArray() throws Exception { JaxWsServerFactoryBean server=getBean(JaxWsServerFactoryBean.class,"ServiceFactory"); server.create(); Cxf1332 client=getBean(Cxf1332.class,"client"); String[] a=new String[]{"a","b","c"}; client.hostSendData(a); assertArrayEquals(a,Cxf1332Impl.getLastStrings()); }

Class: org.apache.cxf.cxf2006.RespectBindingFeatureClientServerTest

InternalCallVerifier EqualityVerifier 
@Test public void testRespectBindingFeatureFalse() throws Exception { startServers("/wsdl_systest/cxf2006.wsdl"); GreeterRPCLit greeter=service.getPort(portName,GreeterRPCLit.class,new RespectBindingFeature(false)); updateAddressPort(greeter,PORT); assertEquals("Bonjour",greeter.sayHi()); }

Class: org.apache.cxf.doclitbare.DocLitBareTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testNamespaceCrash(){ ServerFactoryBean svrFactory=new ServerFactoryBean(); svrFactory.setServiceClass(University.class); svrFactory.setTransportId(LocalTransportFactory.TRANSPORT_ID); svrFactory.setAddress("local://dlbTest"); svrFactory.setServiceBean(new UniversityImpl()); svrFactory.getServiceFactory().setDataBinding(new AegisDatabinding()); svrFactory.create(); ClientProxyFactoryBean factory=new ClientProxyFactoryBean(); factory.getServiceFactory().setDataBinding(new AegisDatabinding()); factory.setServiceClass(University.class); factory.setTransportId(LocalTransportFactory.TRANSPORT_ID); factory.setAddress("local://dlbTest"); University client=(University)factory.create(); Teacher tr=client.getTeacher(new Course(40,"Intro to CS","Introductory Comp Sci")); assertNotNull(tr); assertEquals(52,tr.getAge()); assertEquals("Mr. Tom",tr.getName()); }

Class: org.apache.cxf.ext.logging.DefaultLogEventMapperTest

InternalCallVerifier EqualityVerifier 
/** * Test for NPE described in CXF-6436 */ @Test public void testNullValues(){ DefaultLogEventMapper mapper=new DefaultLogEventMapper(); Message message=new MessageImpl(); message.put(Message.HTTP_REQUEST_METHOD,null); message.put(Message.REQUEST_URI,null); Exchange exchange=new ExchangeImpl(); message.setExchange(exchange); LogEvent event=mapper.map(message); Assert.assertEquals("",event.getOperationName()); }

InternalCallVerifier EqualityVerifier 
@Test public void testRest(){ DefaultLogEventMapper mapper=new DefaultLogEventMapper(); Message message=new MessageImpl(); message.put(Message.HTTP_REQUEST_METHOD,"GET"); message.put(Message.REQUEST_URI,"test"); Exchange exchange=new ExchangeImpl(); message.setExchange(exchange); LogEvent event=mapper.map(message); Assert.assertEquals("GET[test]",event.getOperationName()); }

InternalCallVerifier EqualityVerifier 
@Test public void testSoap(){ DefaultLogEventMapper mapper=new DefaultLogEventMapper(); Message message=new MessageImpl(); ExchangeImpl exchange=new ExchangeImpl(); ServiceInfo service=new ServiceInfo(); BindingInfo info=new BindingInfo(service,"bindingId"); SoapBinding value=new SoapBinding(info); exchange.put(Binding.class,value); OperationInfo opInfo=new OperationInfo(); opInfo.setName(new QName("http://my","Operation")); BindingOperationInfo boi=new BindingOperationInfo(info,opInfo); exchange.put(BindingOperationInfo.class,boi); message.setExchange(exchange); LogEvent event=mapper.map(message); Assert.assertEquals("{http://my}Operation",event.getOperationName()); }

Class: org.apache.cxf.ext.logging.RESTLoggingTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testEvents() throws MalformedURLException { LoggingFeature loggingFeature=new LoggingFeature(); TestEventSender sender=new TestEventSender(); loggingFeature.setSender(sender); Server server=createService(loggingFeature); server.start(); WebClient client=createClient(loggingFeature); String result=client.get(String.class); Assert.assertEquals("test1",result); server.destroy(); List events=sender.getEvents(); Assert.assertEquals(4,events.size()); checkRequestOut(events.get(0)); checkRequestIn(events.get(1)); checkResponseOut(events.get(2)); checkResponseIn(events.get(3)); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testSlf4j() throws IOException { LoggingFeature loggingFeature=new LoggingFeature(); Server server=createService(loggingFeature); server.start(); WebClient client=createClient(loggingFeature); String result=client.get(String.class); Assert.assertEquals("test1",result); server.destroy(); }

Class: org.apache.cxf.ext.logging.SOAPLoggingTest

InternalCallVerifier EqualityVerifier 
@Test public void testEvents() throws MalformedURLException { TestService serviceImpl=new TestServiceImplementation(); LoggingFeature loggingFeature=new LoggingFeature(); TestEventSender sender=new TestEventSender(); loggingFeature.setSender(sender); Endpoint ep=Endpoint.publish(SERVICE_URI,serviceImpl,loggingFeature); TestService client=createTestClient(loggingFeature); client.echo("test"); ep.stop(); List events=sender.getEvents(); Assert.assertEquals(4,events.size()); checkRequestOut(events.get(0)); checkRequestIn(events.get(1)); checkResponseOut(events.get(2)); checkResponseIn(events.get(3)); }

Class: org.apache.cxf.frontend.soap.SoapBindingSelectionTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testMultipleSoapBindings() throws Exception { ServerFactoryBean svrBean1=new ServerFactoryBean(); svrBean1.setAddress("http://localhost/Hello"); svrBean1.setServiceClass(HelloService.class); svrBean1.setServiceBean(new HelloServiceImpl()); svrBean1.setBus(getBus()); svrBean1.getInInterceptors().add(new AbstractPhaseInterceptor(Phase.USER_LOGICAL){ public void handleMessage( Message message) throws Fault { service1Invoked=true; } } ); svrBean1.create(); ServerFactoryBean svrBean2=new ServerFactoryBean(); svrBean2.setAddress("http://localhost/Hello"); svrBean2.setServiceClass(HelloService.class); svrBean2.setServiceBean(new HelloServiceImpl()); svrBean2.setBus(getBus()); svrBean2.getInInterceptors().add(new AbstractPhaseInterceptor(Phase.USER_LOGICAL){ public void handleMessage( Message message) throws Fault { service2Invoked=true; } } ); SoapBindingConfiguration config=new SoapBindingConfiguration(); config.setVersion(Soap12.getInstance()); svrBean2.setBindingConfig(config); ServerImpl server2=(ServerImpl)svrBean2.create(); Destination d=server2.getDestination(); MessageObserver mo=d.getMessageObserver(); assertTrue(mo instanceof MultipleEndpointObserver); MultipleEndpointObserver meo=(MultipleEndpointObserver)mo; assertEquals(2,meo.getEndpoints().size()); Node nd=invoke("http://localhost/Hello",LocalTransportFactory.TRANSPORT_ID,"soap11.xml"); assertEquals("http://schemas.xmlsoap.org/soap/envelope/",getNs(nd)); assertTrue(service1Invoked); assertFalse(service2Invoked); service1Invoked=false; nd=invoke("http://localhost/Hello",LocalTransportFactory.TRANSPORT_ID,"soap12.xml"); assertEquals("http://www.w3.org/2003/05/soap-envelope",getNs(nd)); assertFalse(service1Invoked); assertTrue(service2Invoked); server2.stop(); server2.start(); nd=invoke("http://localhost/Hello",LocalTransportFactory.TRANSPORT_ID,"soap12.xml"); assertEquals("http://www.w3.org/2003/05/soap-envelope",getNs(nd)); assertFalse(service1Invoked); assertTrue(service2Invoked); }

Class: org.apache.cxf.frontend.spring.ClientServerTest

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testClientServer(){ ctx=new ClassPathXmlApplicationContext(new String[]{"/org/apache/cxf/frontend/spring/rountrip.xml"}); HelloService greeter=(HelloService)ctx.getBean("client"); assertNotNull(greeter); String result=greeter.sayHello(); assertEquals("We get the wrong sayHello result","hello",result); Client c=ClientProxy.getClient(greeter); TestInterceptor out=new TestInterceptor(); TestInterceptor in=new TestInterceptor(); c.getRequestContext().put(Message.OUT_INTERCEPTORS,Arrays.asList(new Interceptor[]{out})); result=greeter.sayHello(); assertTrue(out.wasCalled()); out.reset(); c.getRequestContext().put(Message.IN_INTERCEPTORS,Arrays.asList(new Interceptor[]{in})); result=greeter.sayHello(); assertTrue(out.wasCalled()); assertTrue(in.wasCalled()); ctx.close(); BusFactory.setDefaultBus(null); }

Class: org.apache.cxf.frontend.spring.SpringBeansTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testClients() throws Exception { AbstractFactoryBeanDefinitionParser.setFactoriesAreAbstract(false); ctx=new ClassPathXmlApplicationContext(new String[]{"/org/apache/cxf/frontend/spring/clients.xml"}); Object bean=ctx.getBean("client1.proxyFactory"); assertNotNull(bean); ClientProxyFactoryBean cpfbean=(ClientProxyFactoryBean)bean; BindingConfiguration bc=cpfbean.getBindingConfig(); assertTrue(bc instanceof SoapBindingConfiguration); SoapBindingConfiguration sbc=(SoapBindingConfiguration)bc; assertTrue(sbc.getVersion() instanceof Soap12); HelloService greeter=(HelloService)ctx.getBean("client1"); assertNotNull(greeter); Client client=ClientProxy.getClient(greeter); assertNotNull("expected ConduitSelector",client.getConduitSelector()); assertTrue("unexpected ConduitSelector",client.getConduitSelector() instanceof NullConduitSelector); List> inInterceptors=client.getInInterceptors(); boolean saaj=false; boolean logging=false; for ( Interceptor i : inInterceptors) { if (i instanceof SAAJInInterceptor) { saaj=true; } else if (i instanceof LoggingInInterceptor) { logging=true; } } assertTrue(saaj); assertTrue(logging); saaj=false; logging=false; for ( Interceptor i : client.getOutInterceptors()) { if (i instanceof SAAJOutInterceptor) { saaj=true; } else if (i instanceof LoggingOutInterceptor) { logging=true; } } assertTrue(saaj); assertTrue(logging); ClientProxyFactoryBean clientProxyFactoryBean=(ClientProxyFactoryBean)ctx.getBean("client2.proxyFactory"); assertNotNull(clientProxyFactoryBean); assertEquals("get the wrong transportId",clientProxyFactoryBean.getTransportId(),"http://cxf.apache.org/transports/local"); assertEquals("get the wrong bindingId",clientProxyFactoryBean.getBindingId(),"http://cxf.apache.org/bindings/xformat"); greeter=(HelloService)ctx.getBean("client2"); assertNotNull(greeter); greeter=(HelloService)ctx.getBean("client3"); assertNotNull(greeter); client=ClientProxy.getClient(greeter); EndpointInfo epi=client.getEndpoint().getEndpointInfo(); AuthorizationPolicy ap=epi.getExtensor(AuthorizationPolicy.class); assertNotNull("The AuthorizationPolicy instance should not be null",ap); assertEquals("Get the wrong username",ap.getUserName(),"testUser"); assertEquals("Get the wrong password",ap.getPassword(),"password"); }

BranchVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testServers() throws Exception { ctx=new ClassPathXmlApplicationContext(new String[]{"/org/apache/cxf/frontend/spring/servers.xml"}); ServerFactoryBean bean=(ServerFactoryBean)ctx.getBean("simple"); assertNotNull(bean); if (!(bean.getServiceBean() instanceof HelloServiceImpl)) { fail("can't get the right serviceBean"); } bean=(ServerFactoryBean)ctx.getBean("inlineImplementor"); if (!(bean.getServiceBean() instanceof HelloServiceImpl)) { fail("can't get the right serviceBean"); } bean=(ServerFactoryBean)ctx.getBean("inlineSoapBinding"); assertNotNull(bean); BindingConfiguration bc=bean.getBindingConfig(); assertTrue(bc instanceof SoapBindingConfiguration); SoapBindingConfiguration sbc=(SoapBindingConfiguration)bc; assertTrue(sbc.getVersion() instanceof Soap12); bean=(ServerFactoryBean)ctx.getBean("simpleWithBindingId"); assertEquals("get the wrong BindingId",bean.getBindingId(),"http://cxf.apache.org/bindings/xformat"); bean=(ServerFactoryBean)ctx.getBean("simpleWithWSDL"); assertNotNull(bean); assertEquals(bean.getWsdlLocation(),"org/apache/cxf/frontend/spring/simple.wsdl"); bean=(ServerFactoryBean)ctx.getBean("proxyBean"); assertNotNull(bean); }

Class: org.apache.cxf.helpers.HttpHeaderHelperTest

EqualityVerifier 
@Test public void testMapCharset(){ String cs=HttpHeaderHelper.mapCharset("utf-8"); assertEquals(Charset.forName("utf-8").name(),cs); cs=HttpHeaderHelper.mapCharset(null); assertEquals("ISO-8859-1",cs); cs=HttpHeaderHelper.mapCharset("\"utf-8\""); assertEquals(Charset.forName("utf-8").name(),cs); cs=HttpHeaderHelper.mapCharset("'utf-8'"); assertEquals(Charset.forName("utf-8").name(),cs); }

EqualityVerifier 
@Test public void testEmptyCharset2(){ String cs=HttpHeaderHelper.mapCharset(HttpHeaderHelper.findCharset("foo/bar; charset=;")); assertEquals("ISO-8859-1",cs); }

EqualityVerifier 
@Test public void testEmptyCharset(){ String cs=HttpHeaderHelper.mapCharset(HttpHeaderHelper.findCharset("foo/bar; charset=")); assertEquals("ISO-8859-1",cs); }

Class: org.apache.cxf.helpers.NameSpaceTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testNSStackOperations() throws Exception { NSStack nsStackObj=new NSStack(); nsStackObj.push(); nsStackObj.add(MY_URL1); nsStackObj.add(MY_OWN_PREFIX,MY_CUSTOM_URL); nsStackObj.add(MY_URL2); assertEquals(MY_URL1,nsStackObj.getURI("ns1")); assertEquals(MY_CUSTOM_URL,nsStackObj.getURI(MY_OWN_PREFIX)); assertEquals(MY_URL2,nsStackObj.getURI("ns2")); assertNull(nsStackObj.getURI("non-existent-prefix")); assertEquals("ns2",nsStackObj.getPrefix(MY_URL2)); assertEquals(MY_OWN_PREFIX,nsStackObj.getPrefix(MY_CUSTOM_URL)); assertEquals("ns1",nsStackObj.getPrefix(MY_URL1)); assertNull(nsStackObj.getPrefix("non-existent-prefix")); nsStackObj.pop(); assertNull(nsStackObj.getPrefix("non-existent-prefix")); assertNull(nsStackObj.getPrefix(MY_CUSTOM_URL)); }

Class: org.apache.cxf.helpers.ServiceUtilsTest

EqualityVerifier 
@Test public void testmakeNamespaceFromClassName() throws Exception { String tns=ServiceUtils.makeNamespaceFromClassName("com.example.ws.Test","http"); assertEquals("http://ws.example.com/",tns); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetSchemaValidationType(){ for ( SchemaValidationType type : SchemaValidationType.values()) { setupSchemaValidationValue(type.name(),false); assertEquals(type,ServiceUtils.getSchemaValidationType(msg)); setupSchemaValidationValue(type.name().toLowerCase(),false); assertEquals(type,ServiceUtils.getSchemaValidationType(msg)); setupSchemaValidationValue(StringUtils.capitalize(type.name()),false); assertEquals(type,ServiceUtils.getSchemaValidationType(msg)); } }

EqualityVerifier 
@Test public void testGetSchemaValidationTypeBoolean(){ setupSchemaValidationValue(null,false); assertEquals(SchemaValidationType.NONE,ServiceUtils.getSchemaValidationType(msg)); setupSchemaValidationValue("",false); assertEquals(SchemaValidationType.NONE,ServiceUtils.getSchemaValidationType(msg)); setupSchemaValidationValue(Boolean.FALSE,false); assertEquals(SchemaValidationType.NONE,ServiceUtils.getSchemaValidationType(msg)); setupSchemaValidationValue("false",false); assertEquals(SchemaValidationType.NONE,ServiceUtils.getSchemaValidationType(msg)); setupSchemaValidationValue("FALSE",false); assertEquals(SchemaValidationType.NONE,ServiceUtils.getSchemaValidationType(msg)); setupSchemaValidationValue("fAlse",false); assertEquals(SchemaValidationType.NONE,ServiceUtils.getSchemaValidationType(msg)); setupSchemaValidationValue(Boolean.TRUE,false); assertEquals(SchemaValidationType.BOTH,ServiceUtils.getSchemaValidationType(msg)); setupSchemaValidationValue("true",false); assertEquals(SchemaValidationType.BOTH,ServiceUtils.getSchemaValidationType(msg)); setupSchemaValidationValue("TRUE",false); assertEquals(SchemaValidationType.BOTH,ServiceUtils.getSchemaValidationType(msg)); setupSchemaValidationValue("tRue",false); assertEquals(SchemaValidationType.BOTH,ServiceUtils.getSchemaValidationType(msg)); }

Class: org.apache.cxf.interceptor.ServiceInvokerInterceptorTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testInterceptor() throws Exception { ServiceInvokerInterceptor intc=new ServiceInvokerInterceptor(); MessageImpl m=new MessageImpl(); Exchange exchange=new ExchangeImpl(); m.setExchange(exchange); exchange.setInMessage(m); exchange.setOutMessage(new MessageImpl()); TestInvoker i=new TestInvoker(); Endpoint endpoint=createEndpoint(i); exchange.put(Endpoint.class,endpoint); Object input=new Object(); List lst=new ArrayList(); lst.add(input); m.setContent(List.class,lst); intc.handleMessage(m); assertTrue(i.invoked); List list=exchange.getOutMessage().getContent(List.class); assertEquals(input,list.get(0)); }

Class: org.apache.cxf.interceptor.security.DefaultSecurityContextTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testMultipleRoles(){ Subject s=new Subject(); Principal p=new SimplePrincipal("Barry"); s.getPrincipals().add(p); Set roles=new HashSet(); roles.add(new SimpleGroup("friend",p)); roles.add(new SimpleGroup("admin",p)); s.getPrincipals().addAll(roles); LoginSecurityContext context=new DefaultSecurityContext(p,s); assertTrue(context.isUserInRole("friend")); assertTrue(context.isUserInRole("admin")); assertFalse(context.isUserInRole("bar")); Set roles2=context.getUserRoles(); assertEquals(roles2,roles); }

Class: org.apache.cxf.interceptor.security.NamePasswordCallbackHandlerTest

EqualityVerifier 
@Test public void testHandleCallback() throws Exception { NamePasswordCallbackHandler handler=new NamePasswordCallbackHandler("Barry","dog"); Callback[] callbacks=new Callback[]{new NameCallback("name"),new PasswordCallback("password",false)}; handler.handle(callbacks); assertEquals("Barry",((NameCallback)callbacks[0]).getName()); assertEquals("dog",new String(((PasswordCallback)callbacks[1]).getPassword())); }

EqualityVerifier 
@Test public void testHandleCallback4() throws Exception { NamePasswordCallbackHandler handler=new NamePasswordCallbackHandler("Barry","dog","setValue"); Callback[] callbacks=new Callback[]{new NameCallback("name"),new CharArrayCallback()}; handler.handle(callbacks); assertEquals("Barry",((NameCallback)callbacks[0]).getName()); assertEquals("dog",new String(((CharArrayCallback)callbacks[1]).getValue())); }

EqualityVerifier 
@Test public void testHandleCallback3() throws Exception { NamePasswordCallbackHandler handler=new NamePasswordCallbackHandler("Barry","dog"); Callback[] callbacks=new Callback[]{new NameCallback("name"),new StringObjectCallback()}; handler.handle(callbacks); assertEquals("Barry",((NameCallback)callbacks[0]).getName()); assertEquals("dog",((StringObjectCallback)callbacks[1]).getObject()); }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testHandleCallback2() throws Exception { NamePasswordCallbackHandler handler=new NamePasswordCallbackHandler("Barry","dog"); Callback[] callbacks=new Callback[]{new NameCallback("name"),new ObjectCallback()}; handler.handle(callbacks); assertEquals("Barry",((NameCallback)callbacks[0]).getName()); Object pwobj=((ObjectCallback)callbacks[1]).getObject(); assertTrue(pwobj instanceof char[]); assertEquals("dog",new String((char[])pwobj)); }

Class: org.apache.cxf.interceptor.security.RolePrefixSecurityContextImplTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testMultipleRoles(){ Subject s=new Subject(); Principal p=new SimplePrincipal("Barry"); s.getPrincipals().add(p); Set roles=new HashSet(); roles.add(new SimplePrincipal("role_friend")); roles.add(new SimplePrincipal("role_admin")); s.getPrincipals().addAll(roles); LoginSecurityContext context=new RolePrefixSecurityContextImpl(s,"role_"); assertTrue(context.isUserInRole("role_friend")); assertTrue(context.isUserInRole("role_admin")); assertFalse(context.isUserInRole("role_bar")); Set roles2=context.getUserRoles(); assertEquals(roles2,roles); }

Class: org.apache.cxf.io.CachedStreamTestBase

APIUtilityVerifier EqualityVerifier 
@Test public void testResetOut() throws IOException { String result=initTestData(16); Object cache=createCache(); String test=getResetOutValue(result,cache); assertEquals("The test stream content isn't same ",test,result); close(cache); }

Class: org.apache.cxf.javascript.BasicNameManagerTest

InternalCallVerifier EqualityVerifier 
@Test public void testPrefixGeneration(){ BasicNameManager manager=new BasicNameManager(); String jsp=manager.transformURI("http://ThisIsA.Test"); assertEquals("ThisIsA_Test",jsp); jsp=manager.transformURI("uri:george.bill:fred"); assertEquals("george_bill_fred",jsp); }

Class: org.apache.cxf.javascript.DocLitWrappedClientTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void callFunctionWithHeader(){ testUtilities.runInsideContext(Void.class,new JSRunnable(){ public Void run( Context context){ LOG.info("About to call testDummyHeader " + getAddress()); Notifier notifier=testUtilities.rhinoCallConvert("testDummyHeader",Notifier.class,testUtilities.javaToJS(getAddress()),testUtilities.javaToJS("narcissus"),null); boolean notified=notifier.waitForJavascript(1000 * 10); assertTrue(notified); Integer errorStatus=testUtilities.rhinoEvaluateConvert("globalErrorStatus",Integer.class); assertNull(errorStatus); String errorText=testUtilities.rhinoEvaluateConvert("globalErrorStatusText",String.class); assertNull(errorText); Scriptable responseObject=(Scriptable)testUtilities.rhinoEvaluate("globalResponseObject"); assertNotNull(responseObject); String returnValue=testUtilities.rhinoCallMethodInContext(String.class,responseObject,"getReturn"); assertEquals("narcissus",returnValue); return null; } } ); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void inheritedProperties(){ testUtilities.runInsideContext(Void.class,new JSRunnable(){ public Void run( Context context){ Notifier notifier=testUtilities.rhinoCallConvert("testInheritance",Notifier.class,testUtilities.javaToJS(getAddress())); boolean notified=notifier.waitForJavascript(1000 * 10); assertTrue(notified); SimpleDocLitWrappedImpl impl=(SimpleDocLitWrappedImpl)rawImplementor; assertEquals("less",impl.getLastInheritanceTestDerived().getName()); return null; } } ); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void callIntReturnMethod(){ testUtilities.runInsideContext(Void.class,new JSRunnable(){ public Void run( Context context){ LOG.info("About to call test3/IntFunction" + getAddress()); Notifier notifier=testUtilities.rhinoCallConvert("test3",Notifier.class,testUtilities.javaToJS(getAddress()),testUtilities.javaToJS(Double.valueOf(17.0)),testUtilities.javaToJS(Float.valueOf((float)111.0)),testUtilities.javaToJS(Integer.valueOf(142)),testUtilities.javaToJS(Long.valueOf(1240000)),null); boolean notified=notifier.waitForJavascript(1000 * 10); assertTrue(notified); Integer errorStatus=testUtilities.rhinoEvaluateConvert("globalErrorStatus",Integer.class); assertNull(errorStatus); String errorText=testUtilities.rhinoEvaluateConvert("globalErrorStatusText",String.class); assertNull(errorText); Scriptable responseObject=(Scriptable)testUtilities.rhinoEvaluate("globalResponseObject"); assertNotNull(responseObject); int returnValue=testUtilities.rhinoCallMethodInContext(Integer.class,responseObject,"getReturn"); assertEquals(42,returnValue); return null; } } ); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void callMethodWithWrappers(){ testUtilities.runInsideContext(Void.class,new JSRunnable(){ public Void run( Context context){ LOG.info("About to call test1 " + getAddress()); Notifier notifier=testUtilities.rhinoCallConvert("test1",Notifier.class,testUtilities.javaToJS(getAddress()),testUtilities.javaToJS(Double.valueOf(7.0)),testUtilities.javaToJS(Float.valueOf((float)11.0)),testUtilities.javaToJS(Integer.valueOf(42)),testUtilities.javaToJS(Long.valueOf(240000)),"This is the cereal shot from guns"); boolean notified=notifier.waitForJavascript(1000 * 10); assertTrue(notified); Integer errorStatus=testUtilities.rhinoEvaluateConvert("globalErrorStatus",Integer.class); assertNull(errorStatus); String errorText=testUtilities.rhinoEvaluateConvert("globalErrorStatusText",String.class); assertNull(errorText); Scriptable responseObject=(Scriptable)testUtilities.rhinoEvaluate("globalResponseObject"); assertNotNull(responseObject); String returnString=testUtilities.rhinoCallMethodInContext(String.class,responseObject,"getReturnValue"); assertEquals("eels",returnString); return null; } } ); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void callTest2WithNullString(){ testUtilities.runInsideContext(Void.class,new JSRunnable(){ public Void run( Context context){ LOG.info("About to call test2 with null string " + getAddress()); Notifier notifier=testUtilities.rhinoCallConvert("test2",Notifier.class,testUtilities.javaToJS(getAddress()),testUtilities.javaToJS(Double.valueOf(17.0)),testUtilities.javaToJS(Float.valueOf((float)111.0)),testUtilities.javaToJS(Integer.valueOf(142)),testUtilities.javaToJS(Long.valueOf(1240000)),null); boolean notified=notifier.waitForJavascript(1000 * 10); assertTrue(notified); Integer errorStatus=testUtilities.rhinoEvaluateConvert("globalErrorStatus",Integer.class); assertNull(errorStatus); String errorText=testUtilities.rhinoEvaluateConvert("globalErrorStatusText",String.class); assertNull(errorText); Scriptable responseObject=(Scriptable)testUtilities.rhinoEvaluate("globalResponseObject"); assertNotNull(responseObject); String returnString=testUtilities.rhinoCallMethodInContext(String.class,responseObject,"getReturn"); assertEquals("cetaceans",returnString); return null; } } ); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void callMethodWithoutWrappers(){ testUtilities.runInsideContext(Void.class,new JSRunnable(){ public Void run( Context context){ LOG.info("About to call test2 " + getAddress()); Notifier notifier=testUtilities.rhinoCallConvert("test2",Notifier.class,testUtilities.javaToJS(getAddress()),testUtilities.javaToJS(Double.valueOf(17.0)),testUtilities.javaToJS(Float.valueOf((float)111.0)),testUtilities.javaToJS(Integer.valueOf(142)),testUtilities.javaToJS(Long.valueOf(1240000)),"This is the cereal shot from gnus"); boolean notified=notifier.waitForJavascript(1000 * 10); assertTrue(notified); Integer errorStatus=testUtilities.rhinoEvaluateConvert("globalErrorStatus",Integer.class); assertNull(errorStatus); String errorText=testUtilities.rhinoEvaluateConvert("globalErrorStatusText",String.class); assertNull(errorText); Scriptable responseObject=(Scriptable)testUtilities.rhinoEvaluate("globalResponseObject"); assertNotNull(responseObject); String returnString=testUtilities.rhinoCallMethodInContext(String.class,responseObject,"getReturn"); assertEquals("cetaceans",returnString); return null; } } ); }

Class: org.apache.cxf.javascript.JsHttpRequestTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void runTests() throws Exception { testUtilities.rhinoCallExpectingExceptionInContext("SYNTAX_ERR","testOpaqueURI"); testUtilities.rhinoCallExpectingExceptionInContext("SYNTAX_ERR","testNonAbsolute"); testUtilities.rhinoCallExpectingExceptionInContext("SYNTAX_ERR","testNonHttp"); testUtilities.rhinoCallExpectingExceptionInContext("INVALID_STATE_ERR","testSendNotOpenError"); testUtilities.rhinoCallInContext("testStateNotificationSync"); Notifier notifier=testUtilities.rhinoCallConvert("testAsyncHttpFetch1",Notifier.class); testUtilities.rhinoCallInContext("testAsyncHttpFetch2"); boolean notified=notifier.waitForJavascript(2 * 10000); assertTrue(notified); assertEquals("HEADERS_RECEIVED",Boolean.TRUE,testUtilities.rhinoEvaluateConvert("asyncGotHeadersReceived",Boolean.class)); assertEquals("LOADING",Boolean.TRUE,testUtilities.rhinoEvaluateConvert("asyncGotLoading",Boolean.class)); assertEquals("DONE",Boolean.TRUE,testUtilities.rhinoEvaluateConvert("asyncGotDone",Boolean.class)); String outOfOrder=testUtilities.rhinoEvaluateConvert("outOfOrderError",String.class); assertEquals("OutOfOrder",null,outOfOrder); assertEquals("status 200",Integer.valueOf(200),testUtilities.rhinoEvaluateConvert("asyncStatus",Integer.class)); assertEquals("status text","OK",testUtilities.rhinoEvaluateConvert("asyncStatusText",String.class)); assertTrue("headers",testUtilities.rhinoEvaluateConvert("asyncResponseHeaders",String.class).contains("Content-Type: text/html")); Object httpObj=testUtilities.rhinoCallInContext("testSyncHttpFetch"); assertNotNull(httpObj); assertTrue(httpObj instanceof String); String httpResponse=(String)httpObj; assertTrue(httpResponse.contains("\u05e9\u05dc\u05d5\u05dd")); Reader r=getResourceAsReader("/org/apache/cxf/javascript/XML_GreetMeDocLiteralReq.xml"); StringWriter writer=new StringWriter(); char[] buffer=new char[1024]; int readCount; while ((readCount=r.read(buffer,0,1024)) > 0) { writer.write(buffer,0,readCount); } String xml=writer.toString(); EndpointImpl endpoint=this.getBean(EndpointImpl.class,"greeter-service-endpoint"); JsSimpleDomNode xmlResponse=testUtilities.rhinoCallConvert("testSyncXml",JsSimpleDomNode.class,testUtilities.javaToJS(endpoint.getAddress()),testUtilities.javaToJS(xml)); assertNotNull(xmlResponse); Document doc=(Document)xmlResponse.getWrappedNode(); testUtilities.addNamespace("t","http://apache.org/hello_world_xml_http/wrapped/types"); XPath textPath=XPathAssert.createXPath(testUtilities.getNamespaces()); String nodeText=(String)textPath.evaluate("//t:responseType/text()",doc,XPathConstants.STRING); assertEquals("Hello \u05e9\u05dc\u05d5\u05dd",nodeText); }

Class: org.apache.cxf.javascript.QueryHandlerTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void utilsTest() throws Exception { URL endpointURL=new URL(dlbEndpoint.getEndpointInfo().getAddress() + "?js&nojsutils"); URLConnection connection=endpointURL.openConnection(); assertEquals("application/javascript;charset=UTF-8",connection.getContentType()); InputStream jsStream=connection.getInputStream(); String jsString=readStringFromStream(jsStream); assertFalse(jsString.contains("function CxfApacheOrgUtil")); }

APIUtilityVerifier InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void dlbQueryTest() throws Exception { LOG.finest("logged to avoid warning on LOG"); URL endpointURL=new URL(dlbEndpoint.getEndpointInfo().getAddress() + "?js"); URLConnection connection=endpointURL.openConnection(); assertEquals("application/javascript;charset=UTF-8",connection.getContentType()); InputStream jsStream=connection.getInputStream(); String js=readStringFromStream(jsStream); assertNotSame("",js); }

Class: org.apache.cxf.javascript.types.AttributeTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test @org.junit.Ignore public void testSerialization() throws Exception { setupClientAndRhino("simple-dlwu-proxy-factory"); testUtilities.readResourceIntoRhino("/serializationTests.js"); DataBinding dataBinding=clientProxyFactory.getServiceFactory().getDataBinding(); assertNotNull(dataBinding); Object serialized=testUtilities.rhinoCallInContext("serializeTestBean1_1"); assertTrue(serialized instanceof String); String xml=(String)serialized; DataReader reader=dataBinding.createReader(XMLStreamReader.class); StringReader stringReader=new StringReader(xml); XMLStreamReader xmlStreamReader=xmlInputFactory.createXMLStreamReader(stringReader); QName testBeanQName=new QName("uri:org.apache.cxf.javascript.testns","TestBean1"); Object bean=reader.read(testBeanQName,xmlStreamReader,TestBean1.class); assertNotNull(bean); assertTrue(bean instanceof TestBean1); TestBean1 testBean=(TestBean1)bean; assertEquals("bean1

Class: org.apache.cxf.javascript.types.SerializationTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSerialization() throws Exception { setupClientAndRhino("simple-dlwu-proxy-factory"); testUtilities.readResourceIntoRhino("/serializationTests.js"); DataBinding dataBinding=clientProxyFactory.getServiceFactory().getDataBinding(); assertNotNull(dataBinding); Object serialized=testUtilities.rhinoCallInContext("serializeTestBean1_1"); assertTrue(serialized instanceof String); String xml=(String)serialized; DataReader reader=dataBinding.createReader(XMLStreamReader.class); StringReader stringReader=new StringReader(xml); XMLStreamReader xmlStreamReader=xmlInputFactory.createXMLStreamReader(stringReader); QName testBeanQName=new QName("uri:org.apache.cxf.javascript.testns","TestBean1"); Object bean=reader.read(testBeanQName,xmlStreamReader,TestBean1.class); assertNotNull(bean); assertTrue(bean instanceof TestBean1); TestBean1 testBean=(TestBean1)bean; assertEquals("bean1

Class: org.apache.cxf.jaxb.BareInInterceptorTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testInterceptorInbound() throws Exception { setUpUsingHelloWorld(); BareInInterceptor interceptor=new BareInInterceptor(); message.setContent(XMLStreamReader.class,XMLInputFactory.newInstance().createXMLStreamReader(getTestStream(getClass(),"resources/GreetMeDocLiteralReq.xml"))); message.put(Message.INBOUND_MESSAGE,Message.INBOUND_MESSAGE); interceptor.handleMessage(message); assertNull(message.getContent(Exception.class)); List parameters=message.getContent(List.class); assertEquals(1,parameters.size()); Object obj=parameters.get(0); assertTrue(obj instanceof GreetMe); GreetMe greet=(GreetMe)obj; assertEquals("TestSOAPInputPMessage",greet.getRequestType()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testInterceptorInbound1() throws Exception { setUpUsingDocLit(); BareInInterceptor interceptor=new BareInInterceptor(); message.setContent(XMLStreamReader.class,XMLInputFactory.newInstance().createXMLStreamReader(getTestStream(getClass(),"resources/sayHiDocLitBareReq.xml"))); message.put(Message.INBOUND_MESSAGE,Message.INBOUND_MESSAGE); interceptor.handleMessage(message); assertNull(message.getContent(Exception.class)); List parameters=message.getContent(List.class); assertEquals(1,parameters.size()); Object obj=parameters.get(0); assertTrue(obj instanceof TradePriceData); TradePriceData greet=(TradePriceData)obj; assertTrue(1.0 == greet.getTickerPrice()); assertEquals("CXF",greet.getTickerSymbol()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testInterceptorOutbound() throws Exception { setUpUsingHelloWorld(); BareInInterceptor interceptor=new BareInInterceptor(); message.setContent(XMLStreamReader.class,XMLInputFactory.newInstance().createXMLStreamReader(getTestStream(getClass(),"resources/GreetMeDocLiteralResp.xml"))); message.put(Message.REQUESTOR_ROLE,Boolean.TRUE); interceptor.handleMessage(message); List parameters=message.getContent(List.class); assertEquals(1,parameters.size()); Object obj=parameters.get(0); assertTrue(obj instanceof GreetMeResponse); GreetMeResponse greet=(GreetMeResponse)obj; assertEquals("TestSOAPOutputPMessage",greet.getResponseType()); }

Class: org.apache.cxf.jaxb.BareOutInterceptorTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testWriteInbound() throws Exception { GreetMe greetMe=new GreetMe(); greetMe.setRequestType("requestType"); message.setContent(List.class,Arrays.asList(greetMe)); message.put(Message.REQUESTOR_ROLE,Boolean.TRUE); interceptor.handleMessage(message); writer.close(); assertNull(message.getContent(Exception.class)); ByteArrayInputStream bais=new ByteArrayInputStream(baos.toByteArray()); XMLStreamReader xr=StaxUtils.createXMLStreamReader(bais); DepthXMLStreamReader reader=new DepthXMLStreamReader(xr); StaxUtils.toNextElement(reader); assertEquals(new QName("http://apache.org/hello_world_soap_http/types","greetMe"),reader.getName()); StaxUtils.nextEvent(reader); StaxUtils.toNextElement(reader); assertEquals(new QName("http://apache.org/hello_world_soap_http/types","requestType"),reader.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testWriteOutbound() throws Exception { GreetMeResponse greetMe=new GreetMeResponse(); greetMe.setResponseType("responseType"); message.setContent(List.class,Arrays.asList(greetMe)); interceptor.handleMessage(message); writer.close(); assertNull(message.getContent(Exception.class)); ByteArrayInputStream bais=new ByteArrayInputStream(baos.toByteArray()); XMLStreamReader xr=StaxUtils.createXMLStreamReader(bais); DepthXMLStreamReader reader=new DepthXMLStreamReader(xr); StaxUtils.toNextElement(reader); assertEquals(new QName("http://apache.org/hello_world_soap_http/types","greetMeResponse"),reader.getName()); StaxUtils.nextEvent(reader); StaxUtils.toNextElement(reader); assertEquals(new QName("http://apache.org/hello_world_soap_http/types","responseType"),reader.getName()); }

Class: org.apache.cxf.jaxb.DatatypeFactoryTest

EqualityVerifier 
@Test public void testNewFactory() throws Exception { Class.forName("org.apache.cxf.jaxb.DatatypeFactory"); Assert.assertEquals("PT0S",DatatypeFactory.PT0S.toString()); }

Class: org.apache.cxf.jaxb.DocLiteralInInterceptorTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testInterceptorInboundBare() throws Exception { setUpUsingDocLit(); DocLiteralInInterceptor interceptor=new DocLiteralInInterceptor(); message.setContent(XMLStreamReader.class,XMLInputFactory.newInstance().createXMLStreamReader(getTestStream(getClass(),"resources/sayHiDocLitBareReq.xml"))); XMLStreamReader reader=message.getContent(XMLStreamReader.class); StaxUtils.skipToStartOfElement(reader); message.put(Message.INBOUND_MESSAGE,Message.INBOUND_MESSAGE); interceptor.handleMessage(message); assertNull(message.getContent(Exception.class)); List parameters=message.getContent(List.class); assertEquals(1,parameters.size()); Object obj=parameters.get(0); assertTrue(obj instanceof TradePriceData); TradePriceData greet=(TradePriceData)obj; assertTrue(1.0 == greet.getTickerPrice()); assertEquals("CXF",greet.getTickerSymbol()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testInterceptorInboundWrapped() throws Exception { setUpUsingHelloWorld(); DocLiteralInInterceptor interceptor=new DocLiteralInInterceptor(); message.setContent(XMLStreamReader.class,XMLInputFactory.newInstance().createXMLStreamReader(getTestStream(getClass(),"resources/GreetMeDocLiteralReq.xml"))); XMLStreamReader reader=message.getContent(XMLStreamReader.class); StaxUtils.skipToStartOfElement(reader); message.put(Message.INBOUND_MESSAGE,Message.INBOUND_MESSAGE); interceptor.handleMessage(message); assertNull(message.getContent(Exception.class)); List parameters=message.getContent(List.class); assertEquals(1,parameters.size()); Object obj=parameters.get(0); assertTrue(obj instanceof GreetMe); GreetMe greet=(GreetMe)obj; assertEquals("TestSOAPInputPMessage",greet.getRequestType()); }

Class: org.apache.cxf.jaxb.JAXBDataBindingTest

InternalCallVerifier EqualityVerifier 
@Test public void testExtraClass(){ Class[] extraClass=new Class[]{GreetMe.class,GreetMeOneWay.class}; jaxbDataBinding.setExtraClass(extraClass); assertEquals(jaxbDataBinding.getExtraClass().length,2); assertEquals(jaxbDataBinding.getExtraClass()[0],GreetMe.class); assertEquals(jaxbDataBinding.getExtraClass()[1],GreetMeOneWay.class); }

EqualityVerifier 
@Test public void testResursiveType() throws Exception { Set> classes=new HashSet>(); Collection typeReferences=new ArrayList(); Map props=new HashMap(); JAXBContextInitializer init=new JAXBContextInitializer(null,classes,typeReferences,props); init.addClass(Type2.class); assertEquals(2,classes.size()); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSupportedFormats(){ List> cls=Arrays.asList(jaxbDataBinding.getSupportedWriterFormats()); assertNotNull(cls); assertEquals(4,cls.size()); assertTrue(cls.contains(XMLStreamWriter.class)); assertTrue(cls.contains(XMLEventWriter.class)); assertTrue(cls.contains(Node.class)); assertTrue(cls.contains(OutputStream.class)); cls=Arrays.asList(jaxbDataBinding.getSupportedReaderFormats()); assertNotNull(cls); assertEquals(3,cls.size()); assertTrue(cls.contains(XMLStreamReader.class)); assertTrue(cls.contains(XMLEventReader.class)); assertTrue(cls.contains(Node.class)); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testConfiguredXmlAdapter() throws Exception { Language dutch=new Language("nl_NL","Dutch"); Language americanEnglish=new Language("en_US","Americanish"); Person person=new Person(dutch); JAXBDataBinding binding=new JAXBDataBinding(Person.class,Language.class); binding.setConfiguredXmlAdapters(Arrays.>asList(new LanguageAdapter(dutch,americanEnglish))); DataWriter writer=binding.createWriter(OutputStream.class); ByteArrayOutputStream baos=new ByteArrayOutputStream(); writer.write(person,baos); String output=baos.toString(); String xml=""; assertEquals(xml,output); DataReader reader=binding.createReader(XMLStreamReader.class); Person read=(Person)reader.read(XMLInputFactory.newFactory().createXMLStreamReader(new StringReader(xml))); assertEquals(dutch,read.getMotherTongue()); }

Class: org.apache.cxf.jaxb.JAXBEncoderDecoderTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testMarshallIntoStaxEventWriter() throws Exception { GreetMe obj=new GreetMe(); obj.setRequestType("Hello"); QName elName=new QName(wrapperAnnotation.targetNamespace(),wrapperAnnotation.localName()); MessagePartInfo part=new MessagePartInfo(elName,null); part.setElement(true); part.setElementQName(elName); ByteArrayOutputStream baos=new ByteArrayOutputStream(); XMLOutputFactory opFactory=XMLOutputFactory.newInstance(); opFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES,Boolean.TRUE); FixNamespacesXMLEventWriter writer=new FixNamespacesXMLEventWriter(opFactory.createXMLEventWriter(baos)); assertNull(writer.getMarshaller()); Marshaller m=context.createMarshaller(); JAXBEncoderDecoder.marshall(m,obj,part,writer); assertEquals(m,writer.getMarshaller()); writer.flush(); writer.close(); ByteArrayInputStream bais=new ByteArrayInputStream(baos.toByteArray()); XMLInputFactory ipFactory=XMLInputFactory.newInstance(); XMLEventReader reader=ipFactory.createXMLEventReader(bais); Unmarshaller um=context.createUnmarshaller(); Object val=um.unmarshal(reader,GreetMe.class); assertTrue(val instanceof JAXBElement); val=((JAXBElement)val).getValue(); assertTrue(val instanceof GreetMe); assertEquals(obj.getRequestType(),((GreetMe)val).getRequestType()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testMarshallIntoStaxStreamWriter() throws Exception { GreetMe obj=new GreetMe(); obj.setRequestType("Hello"); QName elName=new QName(wrapperAnnotation.targetNamespace(),wrapperAnnotation.localName()); MessagePartInfo part=new MessagePartInfo(elName,null); part.setElement(true); part.setElementQName(elName); ByteArrayOutputStream baos=new ByteArrayOutputStream(); XMLOutputFactory opFactory=XMLOutputFactory.newInstance(); opFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES,Boolean.TRUE); FixNamespacesXMLStreamWriter writer=new FixNamespacesXMLStreamWriter(opFactory.createXMLStreamWriter(baos)); assertNull(writer.getMarshaller()); Marshaller m=context.createMarshaller(); JAXBEncoderDecoder.marshall(m,obj,part,writer); assertEquals(m,writer.getMarshaller()); writer.flush(); writer.close(); ByteArrayInputStream bais=new ByteArrayInputStream(baos.toByteArray()); XMLInputFactory ipFactory=XMLInputFactory.newInstance(); XMLEventReader reader=ipFactory.createXMLEventReader(bais); Unmarshaller um=context.createUnmarshaller(); Object val=um.unmarshal(reader,GreetMe.class); assertTrue(val instanceof JAXBElement); val=((JAXBElement)val).getValue(); assertTrue(val instanceof GreetMe); assertEquals(obj.getRequestType(),((GreetMe)val).getRequestType()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testUnmarshallFromStaxStreamReader() throws Exception { QName elName=new QName(wrapperAnnotation.targetNamespace(),wrapperAnnotation.localName()); MessagePartInfo part=new MessagePartInfo(elName,null); InputStream is=getClass().getResourceAsStream("resources/GreetMeDocLiteralReq.xml"); XMLInputFactory factory=XMLInputFactory.newInstance(); XMLStreamReader reader=factory.createXMLStreamReader(is); QName[] tags={SOAP_ENV,SOAP_BODY}; StaxStreamFilter filter=new StaxStreamFilter(tags); FixNamespacesXMLStreamReader filteredReader=new FixNamespacesXMLStreamReader(factory.createFilteredReader(reader,filter)); assertNull(filteredReader.getUnmarshaller()); part.setTypeClass(GreetMe.class); Unmarshaller um=context.createUnmarshaller(); Object val=JAXBEncoderDecoder.unmarshall(um,filteredReader,part,true); assertEquals(um,filteredReader.getUnmarshaller()); assertNotNull(val); assertTrue(val instanceof GreetMe); assertEquals("TestSOAPInputPMessage",((GreetMe)val).getRequestType()); is.close(); }

APIUtilityVerifier UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testMarshallIntoDOM() throws Exception { String str=new String("Hello"); QName inCorrectElName=new QName("http://test_jaxb_marshall","requestType"); MessagePartInfo part=new MessagePartInfo(inCorrectElName,null); part.setElement(true); part.setElementQName(inCorrectElName); Document doc=DOMUtils.createDocument(); Element elNode=doc.createElementNS(inCorrectElName.getNamespaceURI(),inCorrectElName.getLocalPart()); assertNotNull(elNode); Node node; try { JAXBEncoderDecoder.marshall(context.createMarshaller(),null,part,elNode); fail("Should have thrown a Fault"); } catch ( Fault ex) { } GreetMe obj=new GreetMe(); obj.setRequestType("Hello"); QName elName=new QName(wrapperAnnotation.targetNamespace(),wrapperAnnotation.localName()); part.setElementQName(elName); JAXBEncoderDecoder.marshall(context.createMarshaller(),obj,part,elNode); node=elNode.getLastChild(); assertEquals(Node.ELEMENT_NODE,node.getNodeType()); Node childNode=node.getFirstChild(); assertEquals(Node.ELEMENT_NODE,childNode.getNodeType()); childNode=childNode.getFirstChild(); assertEquals(Node.TEXT_NODE,childNode.getNodeType()); assertEquals(str,childNode.getNodeValue()); StringStruct stringStruct=new StringStruct(); stringStruct.setArg1("world"); JAXBEncoderDecoder.marshall(context.createMarshaller(),stringStruct,part,elNode); try { Marshaller m=context.createMarshaller(); m.setSchema(schema); JAXBEncoderDecoder.marshall(m,stringStruct,part,elNode); fail("Marshal with schema should have thrown a Fault"); } catch ( Fault ex) { } }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testMarshallWithoutQNameInfo() throws Exception { GreetMe obj=new GreetMe(); obj.setRequestType("Hello"); ByteArrayOutputStream baos=new ByteArrayOutputStream(); XMLOutputFactory opFactory=XMLOutputFactory.newInstance(); opFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES,Boolean.TRUE); XMLEventWriter writer=opFactory.createXMLEventWriter(baos); JAXBEncoderDecoder.marshall(context.createMarshaller(),obj,null,writer); writer.flush(); writer.close(); ByteArrayInputStream bais=new ByteArrayInputStream(baos.toByteArray()); XMLInputFactory ipFactory=XMLInputFactory.newInstance(); XMLEventReader reader=ipFactory.createXMLEventReader(bais); Unmarshaller um=context.createUnmarshaller(); Object val=um.unmarshal(reader,GreetMe.class); assertTrue(val instanceof JAXBElement); val=((JAXBElement)val).getValue(); assertTrue(val instanceof GreetMe); assertEquals(obj.getRequestType(),((GreetMe)val).getRequestType()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testUnmarshallWithoutClzInfo() throws Exception { QName elName=new QName(wrapperAnnotation.targetNamespace(),wrapperAnnotation.localName()); Document doc=DOMUtils.createDocument(); Element elNode=doc.createElementNS(elName.getNamespaceURI(),elName.getLocalPart()); Element rtEl=doc.createElementNS(elName.getNamespaceURI(),"requestType"); elNode.appendChild(rtEl); rtEl.appendChild(doc.createTextNode("Hello Test")); Object obj=JAXBEncoderDecoder.unmarshall(context.createUnmarshaller(),elNode,null,true); assertNotNull(obj); assertEquals(GreetMe.class,obj.getClass()); assertEquals("Hello Test",((GreetMe)obj).getRequestType()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testMarshalRPCLit() throws Exception { QName elName=new QName("http://test_jaxb_marshall","in"); MessagePartInfo part=new MessagePartInfo(elName,null); part.setElement(true); part.setElementQName(elName); Document doc=DOMUtils.createDocument(); Element elNode=doc.createElementNS(elName.getNamespaceURI(),elName.getLocalPart()); JAXBEncoderDecoder.marshall(context.createMarshaller(),new String("TestSOAPMessage"),part,elNode); assertEquals("TestSOAPMessage",elNode.getFirstChild().getFirstChild().getNodeValue()); }

APIUtilityVerifier UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testUnMarshall() throws Exception { QName elName=new QName(wrapperAnnotation.targetNamespace(),wrapperAnnotation.localName()); MessagePartInfo part=new MessagePartInfo(elName,null); part.setElement(true); part.setElementQName(elName); part.setTypeClass(Class.forName(wrapperAnnotation.className())); Document doc=DOMUtils.createDocument(); Element elNode=doc.createElementNS(elName.getNamespaceURI(),elName.getLocalPart()); Element rtEl=doc.createElementNS(elName.getNamespaceURI(),"requestType"); elNode.appendChild(rtEl); rtEl.appendChild(doc.createTextNode("Hello Test")); Object obj=JAXBEncoderDecoder.unmarshall(context.createUnmarshaller(),elNode,part,true); assertNotNull(obj); assertEquals(GreetMe.class,obj.getClass()); assertEquals("Hello Test",((GreetMe)obj).getRequestType()); part.setTypeClass(String.class); Node n=null; try { JAXBEncoderDecoder.unmarshall(context.createUnmarshaller(),n,part,true); fail("Should have received a Fault"); } catch ( Fault pe) { } catch ( Exception ex) { fail("Should have received a Fault, not: " + ex); } elName=new QName(wrapperAnnotation.targetNamespace(),"stringStruct"); part=new MessagePartInfo(elName,null); part.setElement(true); part.setElementQName(elName); part.setTypeClass(Class.forName("org.apache.hello_world_soap_http.types.StringStruct")); doc=DOMUtils.createDocument(); elNode=doc.createElementNS(elName.getNamespaceURI(),elName.getLocalPart()); rtEl=doc.createElementNS(elName.getNamespaceURI(),"arg1"); elNode.appendChild(rtEl); rtEl.appendChild(doc.createTextNode("World")); obj=JAXBEncoderDecoder.unmarshall(context.createUnmarshaller(),elNode,part,true); assertNotNull(obj); assertEquals(StringStruct.class,obj.getClass()); assertEquals("World",((StringStruct)obj).getArg1()); try { Unmarshaller m=context.createUnmarshaller(); m.setSchema(schema); obj=JAXBEncoderDecoder.unmarshall(m,elNode,part,true); fail("Should have thrown a Fault"); } catch ( Fault ex) { } }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testUnmarshallFromStaxEventReader() throws Exception { QName elName=new QName(wrapperAnnotation.targetNamespace(),wrapperAnnotation.localName()); MessagePartInfo part=new MessagePartInfo(elName,null); InputStream is=getClass().getResourceAsStream("resources/GreetMeDocLiteralReq.xml"); XMLInputFactory factory=XMLInputFactory.newInstance(); FixNamespacesXMLEventReader reader=new FixNamespacesXMLEventReader(factory.createXMLEventReader(is)); assertNull(reader.getUnmarshaller()); part.setTypeClass(GreetMe.class); Unmarshaller um=context.createUnmarshaller(); Object val=JAXBEncoderDecoder.unmarshall(um,reader,part,true); assertEquals(um,reader.getUnmarshaller()); assertNotNull(val); assertTrue(val instanceof GreetMe); assertEquals("TestSOAPInputPMessage",((GreetMe)val).getRequestType()); is.close(); }

Class: org.apache.cxf.jaxb.JAXBUtilsTest

EqualityVerifier 
@Test public void testPackageNames(){ assertEquals("org.apache.cxf.configuration.types",JAXBUtils.namespaceURIToPackage("http://cxf.apache.org/configuration/types")); assertEquals("auto.org.apache.cxf.configuration.types",JAXBUtils.namespaceURIToPackage("auto://cxf.apache.org/configuration/types")); assertEquals("mouse.org.apache.cxf.configuration.types",JAXBUtils.namespaceURIToPackage("mouse://cxf.apache.org/configuration/types")); assertEquals("h.org.apache.cxf.configuration.types",JAXBUtils.namespaceURIToPackage("h://cxf.apache.org/configuration/types")); assertEquals("org.apache.cxf.configuration.types_h",JAXBUtils.namespaceURIToPackage("http://cxf.apache.org/configuration/types.h")); assertEquals("org.apache.cxf.configuration.types",JAXBUtils.namespaceURIToPackage("http://cxf.apache.org/configuration/types.hi")); assertEquals("org.apache.cxf.configuration.types",JAXBUtils.namespaceURIToPackage("http://cxf.apache.org/configuration/types.xsd")); assertEquals("org.apache.cxf.configuration.types",JAXBUtils.namespaceURIToPackage("http://cxf.apache.org/configuration/types.html")); assertEquals("org.apache.cxf.configuration.types_auto",JAXBUtils.namespaceURIToPackage("http://cxf.apache.org/configuration/types.auto")); assertEquals("org.apache.cxf.configuration.types_mouse",JAXBUtils.namespaceURIToPackage("http://cxf.apache.org/configuration/types.mouse")); assertEquals("https.com.mytech.rosette_analysis",JAXBUtils.namespaceURIToPackage("https://mytech.com/rosette.analysis")); assertEquals("org.apache.cxf.config._4types_",JAXBUtils.namespaceURIToPackage("http://cxf.apache.org/config/4types.")); assertEquals("org.apache.cxf.config_types",JAXBUtils.namespaceURIToPackage("http://cxf.apache.org/config-types")); assertEquals("org.apache.cxf._default.types",JAXBUtils.namespaceURIToPackage("http://cxf.apache.org/default/types")); assertEquals("com.progress.configuration.types",JAXBUtils.namespaceURIToPackage("http://www.progress.com/configuration/types")); assertEquals("org.apache.cxf.config.types",JAXBUtils.namespaceURIToPackage("urn:cxf-apache-org:config:types")); assertEquals("types",JAXBUtils.namespaceURIToPackage("types")); }

EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBuiltInTypeToJavaType(){ assertEquals("boolean",JAXBUtils.builtInTypeToJavaType("boolean")); assertEquals("javax.xml.datatype.XMLGregorianCalendar",JAXBUtils.builtInTypeToJavaType("gYear")); assertNull(JAXBUtils.builtInTypeToJavaType("other")); }

EqualityVerifier 
@Test public void testNameToIdentifier(){ assertEquals("_return",JAXBUtils.nameToIdentifier("return",JAXBUtils.IdentifierType.VARIABLE)); assertEquals("getReturn",JAXBUtils.nameToIdentifier("return",JAXBUtils.IdentifierType.GETTER)); assertEquals("setReturn",JAXBUtils.nameToIdentifier("return",JAXBUtils.IdentifierType.SETTER)); assertEquals("_public",JAXBUtils.nameToIdentifier("public",JAXBUtils.IdentifierType.VARIABLE)); assertEquals("getPublic",JAXBUtils.nameToIdentifier("public",JAXBUtils.IdentifierType.GETTER)); assertEquals("setPublic",JAXBUtils.nameToIdentifier("public",JAXBUtils.IdentifierType.SETTER)); assertEquals("arg0",JAXBUtils.nameToIdentifier("arg0",JAXBUtils.IdentifierType.VARIABLE)); assertEquals("getArg0",JAXBUtils.nameToIdentifier("arg0",JAXBUtils.IdentifierType.GETTER)); assertEquals("setArg0",JAXBUtils.nameToIdentifier("arg0",JAXBUtils.IdentifierType.SETTER)); assertEquals("mixedCaseName",JAXBUtils.nameToIdentifier("mixedCaseName",JAXBUtils.IdentifierType.VARIABLE)); assertEquals("MixedCaseName",JAXBUtils.nameToIdentifier("mixedCaseName",JAXBUtils.IdentifierType.CLASS)); assertEquals("setMixedCaseName",JAXBUtils.nameToIdentifier("mixedCaseName",JAXBUtils.IdentifierType.SETTER)); assertEquals("MIXED_CASE_NAME",JAXBUtils.nameToIdentifier("mixedCaseName",JAXBUtils.IdentifierType.CONSTANT)); assertEquals("answer42",JAXBUtils.nameToIdentifier("Answer42",JAXBUtils.IdentifierType.VARIABLE)); assertEquals("Answer42",JAXBUtils.nameToIdentifier("Answer42",JAXBUtils.IdentifierType.CLASS)); assertEquals("getAnswer42",JAXBUtils.nameToIdentifier("Answer42",JAXBUtils.IdentifierType.GETTER)); assertEquals("ANSWER_42",JAXBUtils.nameToIdentifier("Answer42",JAXBUtils.IdentifierType.CONSTANT)); assertEquals("nameWithDashes",JAXBUtils.nameToIdentifier("name-with-dashes",JAXBUtils.IdentifierType.VARIABLE)); assertEquals("NameWithDashes",JAXBUtils.nameToIdentifier("name-with-dashes",JAXBUtils.IdentifierType.CLASS)); assertEquals("setNameWithDashes",JAXBUtils.nameToIdentifier("name-with-dashes",JAXBUtils.IdentifierType.SETTER)); assertEquals("NAME_WITH_DASHES",JAXBUtils.nameToIdentifier("name-with-dashes",JAXBUtils.IdentifierType.CONSTANT)); assertEquals("otherPunctChars",JAXBUtils.nameToIdentifier("other_punct-chars",JAXBUtils.IdentifierType.VARIABLE)); assertEquals("OtherPunctChars",JAXBUtils.nameToIdentifier("other_punct-chars",JAXBUtils.IdentifierType.CLASS)); assertEquals("getOtherPunctChars",JAXBUtils.nameToIdentifier("other_punct-chars",JAXBUtils.IdentifierType.GETTER)); assertEquals("OTHER_PUNCT_CHARS",JAXBUtils.nameToIdentifier("other_punct-chars",JAXBUtils.IdentifierType.CONSTANT)); }

APIUtilityVerifier EqualityVerifier 
@Test public void testNsToPkg(){ String urn="urn:cxf.apache.org"; String pkg=JAXBUtils.namespaceURIToPackage(urn); assertEquals("org.apache.cxf",pkg); urn="urn:cxf.apache.org:test.v4.6.4"; pkg=JAXBUtils.namespaceURIToPackage(urn); assertEquals("org.apache.cxf.test_v4_6_4",pkg); }

Class: org.apache.cxf.jaxb.JAXBWrapperHelperTest

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void getBooleanTypeWrappedPart() throws Exception { SetIsOK ok=new SetIsOK(); ok.setParameter3(new boolean[]{true,false}); ok.setParameter4("hello"); List partNames=Arrays.asList(new String[]{"Parameter1","Parameter2","Parameter3","Parameter4","Parameter5"}); List elTypeNames=Arrays.asList(new String[]{"boolean","int","boolean","string","string"}); List> partClasses=Arrays.asList(new Class[]{Boolean.TYPE,Integer.TYPE,boolean[].class,String.class,List.class}); WrapperHelper wh=new JAXBDataBinding().createWrapperHelper(SetIsOK.class,null,partNames,elTypeNames,partClasses); List lst=wh.getWrapperParts(ok); assertEquals(5,lst.size()); assertTrue(lst.get(0) instanceof Boolean); assertTrue(lst.get(1) instanceof Integer); assertTrue(lst.get(2) instanceof boolean[]); assertTrue(((boolean[])lst.get(2))[0]); assertFalse(((boolean[])lst.get(2))[1]); assertEquals("hello",lst.get(3)); lst.set(0,Boolean.TRUE); Object o=wh.createWrapperObject(lst); assertNotNull(0); ok=(SetIsOK)o; assertTrue(ok.isParameter1()); assertTrue(ok.getParameter3()[0]); assertFalse(ok.getParameter3()[1]); assertEquals("hello",ok.getParameter4()); }

Class: org.apache.cxf.jaxb.io.XMLStreamDataReaderTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testSetProperty() throws Exception { MyCustomHandler handler=new MyCustomHandler(); DataReaderImpl dr=newDataReader(handler); Object val=dr.read(reader); assertTrue(val instanceof GreetMe); assertEquals("TestSOAPInputPMessage",((GreetMe)val).getRequestType()); assertTrue(handler.getUsed()); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testReadBare() throws Exception { JAXBDataBinding db=getDataBinding(TradePriceData.class); reader=getTestReader("../resources/sayHiDocLitBareReq.xml"); assertNotNull(reader); DataReader dr=db.createReader(XMLStreamReader.class); assertNotNull(dr); QName elName=new QName("http://apache.org/hello_world_doc_lit_bare/types","inout"); MessagePartInfo part=new MessagePartInfo(elName,null); part.setElement(true); part.setElementQName(elName); part.setTypeClass(TradePriceData.class); Object val=dr.read(part,reader); assertNotNull(val); assertTrue(val instanceof TradePriceData); assertEquals("CXF",((TradePriceData)val).getTickerSymbol()); assertEquals(new Float(1.0f),new Float(((TradePriceData)val).getTickerPrice())); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testReadRPC() throws Exception { JAXBDataBinding db=getDataBinding(MyComplexStruct.class); QName[] tags={new QName("http://apache.org/hello_world_rpclit","sendReceiveData")}; reader=getTestReader("../resources/greetMeRpcLitReq.xml"); assertNotNull(reader); XMLStreamReader localReader=getTestFilteredReader(reader,tags); DataReader dr=db.createReader(XMLStreamReader.class); assertNotNull(dr); Object val=dr.read(new QName("http://apache.org/hello_world_rpclit","in"),localReader,MyComplexStruct.class); assertNotNull(val); assertTrue(val instanceof MyComplexStruct); assertEquals("this is element 1",((MyComplexStruct)val).getElem1()); assertEquals("this is element 2",((MyComplexStruct)val).getElem2()); assertEquals(42,((MyComplexStruct)val).getElem3()); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testReadWrapperReturn() throws Exception { JAXBDataBinding db=getDataBinding(GreetMeResponse.class); reader=getTestReader("../resources/GreetMeDocLiteralResp.xml"); assertNotNull(reader); DataReader dr=db.createReader(XMLStreamReader.class); assertNotNull(dr); Object retValue=dr.read(reader); assertNotNull(retValue); assertTrue(retValue instanceof GreetMeResponse); assertEquals("TestSOAPOutputPMessage",((GreetMeResponse)retValue).getResponseType()); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testReadWrapper() throws Exception { JAXBDataBinding db=getDataBinding(GreetMe.class); reader=getTestReader("../resources/GreetMeDocLiteralReq.xml"); assertNotNull(reader); DataReader dr=db.createReader(XMLStreamReader.class); assertNotNull(dr); Object val=dr.read(reader); assertNotNull(val); assertTrue(val instanceof GreetMe); assertEquals("TestSOAPInputPMessage",((GreetMe)val).getRequestType()); }

Class: org.apache.cxf.jaxb.io.XMLStreamDataWriterTest

APIUtilityVerifier BranchVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testWriteWithContextualNamespaceDecls() throws Exception { JAXBDataBinding db=getTestWriterFactory(GreetMe.class); Map nspref=new HashMap(); nspref.put("http://apache.org/hello_world_soap_http/types","x"); db.setNamespaceMap(nspref); db.setContextualNamespaceMap(nspref); DataWriter dw=db.createWriter(OutputStream.class); assertNotNull(dw); GreetMe val=new GreetMe(); val.setRequestType("Hello"); dw.write(val,baos); String xstr=new String(baos.toByteArray()); if (!db.getContext().getClass().getName().contains("eclipse")) { assertEquals("Hello",xstr); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testWriteBare() throws Exception { JAXBDataBinding db=getTestWriterFactory(TradePriceData.class); DataWriter dw=db.createWriter(XMLStreamWriter.class); assertNotNull(dw); TradePriceData val=new TradePriceData(); val.setTickerSymbol("This is a symbol"); val.setTickerPrice(1.0f); QName elName=new QName("http://apache.org/hello_world_doc_lit_bare/types","inout"); MessagePartInfo part=new MessagePartInfo(elName,null); part.setElement(true); part.setElementQName(elName); dw.write(val,part,streamWriter); streamWriter.flush(); ByteArrayInputStream bais=new ByteArrayInputStream(baos.toByteArray()); XMLStreamReader xr=inFactory.createXMLStreamReader(bais); DepthXMLStreamReader reader=new DepthXMLStreamReader(xr); StaxUtils.toNextElement(reader); assertEquals(new QName("http://apache.org/hello_world_doc_lit_bare/types","inout"),reader.getName()); StaxUtils.nextEvent(reader); StaxUtils.toNextElement(reader); assertEquals(new QName("http://apache.org/hello_world_doc_lit_bare/types","tickerSymbol"),reader.getName()); StaxUtils.nextEvent(reader); StaxUtils.toNextText(reader); assertEquals("This is a symbol",reader.getText()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testWriteWithNamespacePrefixMapping() throws Exception { JAXBDataBinding db=getTestWriterFactory(GreetMe.class); Map nspref=new HashMap(); nspref.put("http://apache.org/hello_world_soap_http/types","x"); db.setNamespaceMap(nspref); DataWriter dw=db.createWriter(OutputStream.class); assertNotNull(dw); GreetMe val=new GreetMe(); val.setRequestType("Hello"); dw.write(val,baos); ByteArrayInputStream bais=new ByteArrayInputStream(baos.toByteArray()); XMLStreamReader xr=inFactory.createXMLStreamReader(bais); DepthXMLStreamReader reader=new DepthXMLStreamReader(xr); StaxUtils.toNextElement(reader); QName qname=reader.getName(); assertEquals(new QName("http://apache.org/hello_world_soap_http/types","greetMe"),qname); assertEquals("x",qname.getPrefix()); assertEquals(1,reader.getNamespaceCount()); assertEquals("http://apache.org/hello_world_soap_http/types",reader.getNamespaceURI(0)); assertEquals("x",reader.getNamespacePrefix(0)); StaxUtils.nextEvent(reader); StaxUtils.toNextElement(reader); qname=reader.getName(); assertEquals(new QName("http://apache.org/hello_world_soap_http/types","requestType"),qname); assertEquals("x",qname.getPrefix()); StaxUtils.nextEvent(reader); StaxUtils.toNextText(reader); assertEquals("Hello",reader.getText()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testWriteWrapperReturn() throws Exception { JAXBDataBinding db=getTestWriterFactory(GreetMeResponse.class); DataWriter dw=db.createWriter(XMLStreamWriter.class); assertNotNull(dw); GreetMeResponse retVal=new GreetMeResponse(); retVal.setResponseType("TESTOUTPUTMESSAGE"); dw.write(retVal,streamWriter); streamWriter.flush(); ByteArrayInputStream bais=new ByteArrayInputStream(baos.toByteArray()); XMLStreamReader xr=inFactory.createXMLStreamReader(bais); DepthXMLStreamReader reader=new DepthXMLStreamReader(xr); StaxUtils.toNextElement(reader); assertEquals(new QName("http://apache.org/hello_world_soap_http/types","greetMeResponse"),reader.getName()); StaxUtils.nextEvent(reader); StaxUtils.toNextElement(reader); assertEquals(new QName("http://apache.org/hello_world_soap_http/types","responseType"),reader.getName()); StaxUtils.nextEvent(reader); StaxUtils.toNextText(reader); assertEquals("TESTOUTPUTMESSAGE",reader.getText()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testWriteRPCLit1() throws Exception { JAXBDataBinding db=getTestWriterFactory(); DataWriter dw=db.createWriter(XMLStreamWriter.class); assertNotNull(dw); String val=new String("TESTOUTPUTMESSAGE"); QName elName=new QName("http://apache.org/hello_world_rpclit/types","in"); MessagePartInfo part=new MessagePartInfo(elName,null); part.setElement(true); part.setElementQName(elName); dw.write(val,part,streamWriter); streamWriter.flush(); ByteArrayInputStream bais=new ByteArrayInputStream(baos.toByteArray()); XMLStreamReader xr=inFactory.createXMLStreamReader(bais); DepthXMLStreamReader reader=new DepthXMLStreamReader(xr); StaxUtils.toNextElement(reader); assertEquals(new QName("http://apache.org/hello_world_rpclit/types","in"),reader.getName()); StaxUtils.nextEvent(reader); StaxUtils.toNextText(reader); assertEquals("TESTOUTPUTMESSAGE",reader.getText()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testWriteRPCLit2() throws Exception { JAXBDataBinding db=getTestWriterFactory(MyComplexStruct.class); DataWriter dw=db.createWriter(XMLStreamWriter.class); assertNotNull(dw); MyComplexStruct val=new MyComplexStruct(); val.setElem1("This is element 1"); val.setElem2("This is element 2"); val.setElem3(1); QName elName=new QName("http://apache.org/hello_world_rpclit/types","in"); MessagePartInfo part=new MessagePartInfo(elName,null); part.setElement(true); part.setElementQName(elName); dw.write(val,part,streamWriter); streamWriter.flush(); ByteArrayInputStream bais=new ByteArrayInputStream(baos.toByteArray()); XMLStreamReader xr=inFactory.createXMLStreamReader(bais); DepthXMLStreamReader reader=new DepthXMLStreamReader(xr); StaxUtils.toNextElement(reader); assertEquals(new QName("http://apache.org/hello_world_rpclit/types","in"),reader.getName()); StaxUtils.nextEvent(reader); StaxUtils.toNextElement(reader); assertEquals(new QName("http://apache.org/hello_world_rpclit/types","elem1"),reader.getName()); StaxUtils.nextEvent(reader); StaxUtils.toNextText(reader); assertEquals("This is element 1",reader.getText()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testWriteWrapper() throws Exception { JAXBDataBinding db=getTestWriterFactory(GreetMe.class); DataWriter dw=db.createWriter(XMLStreamWriter.class); assertNotNull(dw); GreetMe val=new GreetMe(); val.setRequestType("Hello"); dw.write(val,streamWriter); streamWriter.flush(); ByteArrayInputStream bais=new ByteArrayInputStream(baos.toByteArray()); XMLStreamReader xr=inFactory.createXMLStreamReader(bais); DepthXMLStreamReader reader=new DepthXMLStreamReader(xr); StaxUtils.toNextElement(reader); assertEquals(new QName("http://apache.org/hello_world_soap_http/types","greetMe"),reader.getName()); StaxUtils.nextEvent(reader); StaxUtils.toNextElement(reader); assertEquals(new QName("http://apache.org/hello_world_soap_http/types","requestType"),reader.getName()); StaxUtils.nextEvent(reader); StaxUtils.toNextText(reader); assertEquals("Hello",reader.getText()); }

Class: org.apache.cxf.jaxrs.JAXRSServiceFactoryBeanTest

InternalCallVerifier EqualityVerifier 
@Test public void testSubresourcesOnlyDynamicResolution() throws Exception { JAXRSServiceFactoryBean sf=new JAXRSServiceFactoryBean(); sf.setResourceClasses(org.apache.cxf.jaxrs.resources.BookStoreSubresourcesOnly.class); sf.create(); List resources=((JAXRSServiceImpl)sf.getService()).getClassResourceInfos(); assertEquals(1,resources.size()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testNoSubResources() throws Exception { JAXRSServiceFactoryBean sf=new JAXRSServiceFactoryBean(); sf.setEnableStaticResolution(true); sf.setResourceClasses(org.apache.cxf.jaxrs.resources.BookStoreNoSubResource.class); sf.create(); List resources=((JAXRSServiceImpl)sf.getService()).getClassResourceInfos(); assertEquals(1,resources.size()); ClassResourceInfo rootCri=resources.get(0); assertNotNull(rootCri.getURITemplate()); URITemplate template=rootCri.getURITemplate(); MultivaluedMap values=new MetadataMap(); assertTrue(template.match("/bookstore/books/123",values)); assertFalse(rootCri.hasSubResources()); MethodDispatcher md=rootCri.getMethodDispatcher(); assertEquals(7,md.getOperationResourceInfos().size()); Set ops=md.getOperationResourceInfos(); assertTrue("No operation found",verifyOp(ops,"getBook","GET",false)); assertTrue("No operation found",verifyOp(ops,"getBookStoreInfo","GET",false)); assertTrue("No operation found",verifyOp(ops,"getBooks","GET",false)); assertTrue("No operation found",verifyOp(ops,"getBookJSON","GET",false)); assertTrue("No operation found",verifyOp(ops,"addBook","POST",false)); assertTrue("No operation found",verifyOp(ops,"updateBook","PUT",false)); assertTrue("No operation found",verifyOp(ops,"deleteBook","DELETE",false)); }

APIUtilityVerifier BranchVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSubResources() throws Exception { JAXRSServiceFactoryBean sf=new JAXRSServiceFactoryBean(); sf.setEnableStaticResolution(true); sf.setResourceClasses(org.apache.cxf.jaxrs.resources.BookStore.class); sf.create(); List resources=((JAXRSServiceImpl)sf.getService()).getClassResourceInfos(); assertEquals(1,resources.size()); ClassResourceInfo rootCri=resources.get(0); assertNotNull(rootCri.getURITemplate()); URITemplate template=rootCri.getURITemplate(); MultivaluedMap values=new MetadataMap(); assertTrue(template.match("/bookstore/books/123",values)); assertTrue(rootCri.hasSubResources()); MethodDispatcher md=rootCri.getMethodDispatcher(); assertEquals(7,md.getOperationResourceInfos().size()); for ( OperationResourceInfo ori : md.getOperationResourceInfos()) { if ("getDescription".equals(ori.getMethodToInvoke().getName())) { assertEquals("GET",ori.getHttpMethod()); assertEquals("/path",ori.getURITemplate().getValue()); assertEquals("text/bar",ori.getProduceTypes().get(0).toString()); assertEquals("text/foo",ori.getConsumeTypes().get(0).toString()); assertFalse(ori.isSubResourceLocator()); } else if ("getAuthor".equals(ori.getMethodToInvoke().getName())) { assertEquals("GET",ori.getHttpMethod()); assertEquals("/path2",ori.getURITemplate().getValue()); assertEquals("text/bar2",ori.getProduceTypes().get(0).toString()); assertEquals("text/foo2",ori.getConsumeTypes().get(0).toString()); assertFalse(ori.isSubResourceLocator()); } else if ("getBook".equals(ori.getMethodToInvoke().getName())) { assertNull(ori.getHttpMethod()); assertNotNull(ori.getURITemplate()); assertTrue(ori.isSubResourceLocator()); } else if ("getNewBook".equals(ori.getMethodToInvoke().getName())) { assertNull(ori.getHttpMethod()); assertNotNull(ori.getURITemplate()); assertTrue(ori.isSubResourceLocator()); } else if ("addBook".equals(ori.getMethodToInvoke().getName())) { assertEquals("POST",ori.getHttpMethod()); assertNotNull(ori.getURITemplate()); assertFalse(ori.isSubResourceLocator()); } else if ("updateBook".equals(ori.getMethodToInvoke().getName())) { assertEquals("PUT",ori.getHttpMethod()); assertNotNull(ori.getURITemplate()); assertFalse(ori.isSubResourceLocator()); } else if ("deleteBook".equals(ori.getMethodToInvoke().getName())) { assertEquals("DELETE",ori.getHttpMethod()); assertNotNull(ori.getURITemplate()); assertFalse(ori.isSubResourceLocator()); } else { fail("unexpected OperationResourceInfo" + ori.getMethodToInvoke().getName()); } } assertEquals(1,rootCri.getSubResources().size()); ClassResourceInfo subCri=rootCri.getSubResources().iterator().next(); assertNull(subCri.getURITemplate()); assertEquals(org.apache.cxf.jaxrs.resources.Book.class,subCri.getResourceClass()); MethodDispatcher subMd=subCri.getMethodDispatcher(); assertEquals(2,subMd.getOperationResourceInfos().size()); OperationResourceInfo subOri=subMd.getOperationResourceInfos().iterator().next(); assertEquals("GET",subOri.getHttpMethod()); assertNotNull(subOri.getURITemplate()); OperationResourceInfo subOri2=subMd.getOperationResourceInfos().iterator().next(); assertEquals("GET",subOri2.getHttpMethod()); assertNotNull(subOri2.getURITemplate()); }

Class: org.apache.cxf.jaxrs.SelectMethodCandidatesTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testFindFromAbstractGenericClass3() throws Exception { JAXRSServiceFactoryBean sf=new JAXRSServiceFactoryBean(); sf.setResourceClasses(BookEntity.class); sf.create(); List resources=((JAXRSServiceImpl)sf.getService()).getClassResourceInfos(); String contentTypes="text/xml"; String acceptContentTypes="text/xml"; Message m=new MessageImpl(); m.put(Message.CONTENT_TYPE,"text/xml"); Exchange ex=new ExchangeImpl(); ex.setInMessage(m); m.setExchange(ex); Endpoint e=EasyMock.createMock(Endpoint.class); e.isEmpty(); EasyMock.expectLastCall().andReturn(true).anyTimes(); e.size(); EasyMock.expectLastCall().andReturn(0).anyTimes(); e.getEndpointInfo(); EasyMock.expectLastCall().andReturn(null).anyTimes(); e.get(ServerProviderFactory.class.getName()); EasyMock.expectLastCall().andReturn(ServerProviderFactory.getInstance()).times(3); e.get("org.apache.cxf.jaxrs.comparator"); EasyMock.expectLastCall().andReturn(null); EasyMock.replay(e); ex.put(Endpoint.class,e); MetadataMap values=new MetadataMap(); OperationResourceInfo ori=findTargetResourceClass(resources,m,"/books","PUT",values,contentTypes,sortMediaTypes(acceptContentTypes)); assertNotNull(ori); assertEquals("resourceMethod needs to be selected","putEntity",ori.getMethodToInvoke().getName()); String value="The Book2"; m.setContent(InputStream.class,new ByteArrayInputStream(value.getBytes())); List params=JAXRSUtils.processParameters(ori,values,m); assertEquals(1,params.size()); Chapter c=(Chapter)params.get(0); assertNotNull(c); assertEquals(2L,c.getId()); assertEquals("The Book",c.getTitle()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testFindFromAbstractGenericImpl4() throws Exception { JAXRSServiceFactoryBean sf=new JAXRSServiceFactoryBean(); sf.setResourceClasses(GenericEntityImpl4.class); sf.create(); List resources=((JAXRSServiceImpl)sf.getService()).getClassResourceInfos(); String contentTypes="text/xml"; String acceptContentTypes="text/xml"; Message m=new MessageImpl(); m.put(Message.CONTENT_TYPE,"text/xml"); Exchange ex=new ExchangeImpl(); ex.setInMessage(m); m.setExchange(ex); Endpoint e=EasyMock.createMock(Endpoint.class); e.isEmpty(); EasyMock.expectLastCall().andReturn(true).anyTimes(); e.size(); EasyMock.expectLastCall().andReturn(0).anyTimes(); e.getEndpointInfo(); EasyMock.expectLastCall().andReturn(null).anyTimes(); e.get(ServerProviderFactory.class.getName()); EasyMock.expectLastCall().andReturn(ServerProviderFactory.getInstance()).times(2); e.get("org.apache.cxf.jaxrs.comparator"); EasyMock.expectLastCall().andReturn(null); EasyMock.replay(e); ex.put(Endpoint.class,e); MetadataMap values=new MetadataMap(); OperationResourceInfo ori=findTargetResourceClass(resources,m,"/books","POST",values,contentTypes,sortMediaTypes(acceptContentTypes)); assertNotNull(ori); assertEquals("resourceMethod needs to be selected","postEntity",ori.getMethodToInvoke().getName()); String value="The Book2"; m.setContent(InputStream.class,new ByteArrayInputStream(value.getBytes())); List params=JAXRSUtils.processParameters(ori,values,m); assertEquals(1,params.size()); List books=(List)params.get(0); assertEquals(1,books.size()); Book book=(Book)books.get(0); assertNotNull(book); assertEquals(2L,book.getId()); assertEquals("The Book",book.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSelectBar() throws Exception { JAXRSServiceFactoryBean sf=new JAXRSServiceFactoryBean(); sf.setResourceClasses(org.apache.cxf.jaxrs.resources.TestResource.class); sf.create(); List resources=((JAXRSServiceImpl)sf.getService()).getClassResourceInfos(); String contentTypes="*/*"; String acceptContentTypes="application/bar,application/foo;q=0.8"; MetadataMap values=new MetadataMap(); OperationResourceInfo ori=findTargetResourceClass(resources,null,"/1/2/3/d/custom","GET",values,contentTypes,sortMediaTypes(acceptContentTypes)); assertNotNull(ori); assertEquals("readBar",ori.getMethodToInvoke().getName()); acceptContentTypes="application/foo,application/bar;q=0.8"; ori=findTargetResourceClass(resources,null,"/1/2/3/d/custom","GET",values,contentTypes,sortMediaTypes(acceptContentTypes)); assertNotNull(ori); assertEquals("readFoo",ori.getMethodToInvoke().getName()); acceptContentTypes="application/foo;q=0.5,application/bar"; ori=findTargetResourceClass(resources,null,"/1/2/3/d/custom","GET",values,contentTypes,sortMediaTypes(acceptContentTypes)); assertNotNull(ori); assertEquals("readBar",ori.getMethodToInvoke().getName()); acceptContentTypes="application/foo,application/bar;q=0.5"; ori=findTargetResourceClass(resources,null,"/1/2/3/d/custom","GET",values,contentTypes,sortMediaTypes(acceptContentTypes)); assertNotNull(ori); assertEquals("readFoo",ori.getMethodToInvoke().getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testFindFromAbstractGenericImpl5() throws Exception { JAXRSServiceFactoryBean sf=new JAXRSServiceFactoryBean(); sf.setResourceClasses(ConcreteRestController.class); sf.create(); List resources=((JAXRSServiceImpl)sf.getService()).getClassResourceInfos(); Message m=createMessage(); m.put(Message.CONTENT_TYPE,"text/xml"); MetadataMap values=new MetadataMap(); OperationResourceInfo ori=findTargetResourceClass(resources,m,"/","POST",values,"text/xml",sortMediaTypes("*/*")); assertNotNull(ori); assertEquals("resourceMethod needs to be selected","add",ori.getMethodToInvoke().getName()); String value="The Book"; m.setContent(InputStream.class,new ByteArrayInputStream(value.getBytes())); List params=JAXRSUtils.processParameters(ori,values,m); assertEquals(1,params.size()); ConcreteRestResource book=(ConcreteRestResource)params.get(0); assertNotNull(book); assertEquals("The Book",book.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testFindTargetResourceClassWithTemplates() throws Exception { JAXRSServiceFactoryBean sf=new JAXRSServiceFactoryBean(); sf.setResourceClasses(org.apache.cxf.jaxrs.resources.TestResource.class); sf.create(); List resources=((JAXRSServiceImpl)sf.getService()).getClassResourceInfos(); String contentTypes="*/*"; String acceptContentTypes="application/xml"; MetadataMap values=new MetadataMap(); OperationResourceInfo ori=findTargetResourceClass(resources,createMessage(),"/1/2/3/d","GET",values,contentTypes,Collections.singletonList(MediaType.valueOf(acceptContentTypes))); assertNotNull(ori); assertEquals("listMethod needs to be selected","listMethod",ori.getMethodToInvoke().getName()); acceptContentTypes="application/xml,application/json;q=0.8"; ori=findTargetResourceClass(resources,null,"/1/2/3/d/1","GET",values,contentTypes,JAXRSUtils.parseMediaTypes(acceptContentTypes)); assertNotNull(ori); assertEquals("readMethod needs to be selected","readMethod",ori.getMethodToInvoke().getName()); contentTypes="application/xml"; acceptContentTypes="application/xml"; ori=findTargetResourceClass(resources,null,"/1/2/3/d/1","GET",values,contentTypes,Collections.singletonList(MediaType.valueOf(acceptContentTypes))); assertNotNull(ori); assertEquals("readMethod needs to be selected","readMethod",ori.getMethodToInvoke().getName()); contentTypes="application/json"; acceptContentTypes="application/json"; ori=findTargetResourceClass(resources,null,"/1/2/3/d/1/bar/baz/baz","GET",values,contentTypes,Collections.singletonList(MediaType.valueOf(acceptContentTypes))); assertNotNull(ori); assertEquals("readMethod2 needs to be selected","readMethod2",ori.getMethodToInvoke().getName()); contentTypes="application/json"; acceptContentTypes="application/json"; ori=findTargetResourceClass(resources,null,"/1/2/3/d/1","GET",values,contentTypes,Collections.singletonList(MediaType.valueOf(acceptContentTypes))); assertNotNull(ori); assertEquals("unlimitedPath needs to be selected","unlimitedPath",ori.getMethodToInvoke().getName()); ori=findTargetResourceClass(resources,null,"/1/2/3/d/1/2","GET",values,contentTypes,Collections.singletonList(MediaType.valueOf(acceptContentTypes))); assertNotNull(ori); assertEquals("limitedPath needs to be selected","limitedPath",ori.getMethodToInvoke().getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSelectUsingQualityFactors() throws Exception { JAXRSServiceFactoryBean sf=new JAXRSServiceFactoryBean(); sf.setResourceClasses(org.apache.cxf.jaxrs.resources.TestResource.class); sf.create(); List resources=((JAXRSServiceImpl)sf.getService()).getClassResourceInfos(); String contentTypes="*/*"; String acceptContentTypes="application/xml;q=0.5,application/json"; MetadataMap values=new MetadataMap(); OperationResourceInfo ori=findTargetResourceClass(resources,createMessage(),"/1/2/3/d/resource1","GET",values,contentTypes,sortMediaTypes(acceptContentTypes)); assertNotNull(ori); assertEquals("jsonResource needs to be selected","jsonResource",ori.getMethodToInvoke().getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDefaultMethod() throws Exception { JAXRSServiceFactoryBean sf=new JAXRSServiceFactoryBean(); sf.setResourceClasses(DefaultMethodResource.class); sf.create(); List resources=((JAXRSServiceImpl)sf.getService()).getClassResourceInfos(); String contentType="text/xml"; String acceptContentTypes="text/xml"; Message m=new MessageImpl(); m.put(Message.CONTENT_TYPE,contentType); Exchange ex=new ExchangeImpl(); ex.setInMessage(m); m.setExchange(ex); Endpoint e=EasyMock.createMock(Endpoint.class); e.isEmpty(); EasyMock.expectLastCall().andReturn(true).anyTimes(); e.size(); EasyMock.expectLastCall().andReturn(0).anyTimes(); e.getEndpointInfo(); EasyMock.expectLastCall().andReturn(null).anyTimes(); e.get(ServerProviderFactory.class.getName()); EasyMock.expectLastCall().andReturn(ServerProviderFactory.getInstance()).times(3); e.get("org.apache.cxf.jaxrs.comparator"); EasyMock.expectLastCall().andReturn(null); EasyMock.replay(e); ex.put(Endpoint.class,e); MetadataMap values=new MetadataMap(); OperationResourceInfo ori=findTargetResourceClass(resources,m,"/service/all","PUT",values,contentType,sortMediaTypes(acceptContentTypes)); assertNotNull(ori); assertEquals("resourceMethod needs to be selected","all",ori.getMethodToInvoke().getName()); values.clear(); ori=findTargetResourceClass(resources,m,"/service/all","GET",values,contentType,sortMediaTypes(acceptContentTypes)); assertNotNull(ori); assertEquals("resourceMethod needs to be selected","getAll",ori.getMethodToInvoke().getName()); ori=findTargetResourceClass(resources,m,"/service","GET",values,contentType,sortMediaTypes(acceptContentTypes)); assertNotNull(ori); assertEquals("resourceMethod needs to be selected","get",ori.getMethodToInvoke().getName()); }

Class: org.apache.cxf.jaxrs.client.JAXRSClientFactoryBeanTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testAddLoggingToClient() throws Exception { JAXRSClientFactoryBean bean=new JAXRSClientFactoryBean(); bean.setAddress("http://bar"); bean.setResourceClass(BookStoreSubresourcesOnly.class); TestFeature testFeature=new TestFeature(); List features=new ArrayList(); features.add(testFeature); bean.setFeatures(features); BookStoreSubresourcesOnly store=bean.create(BookStoreSubresourcesOnly.class,1,2,3); assertTrue("TestFeature wasn't initialized",testFeature.isInitialized()); BookStoreSubresourcesOnly store2=store.getItself3("id4"); assertEquals("http://bar/bookstore/1/2/3/id4/sub3",WebClient.client(store2).getCurrentURI().toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testTemplateInRootReplaceEmpty() throws Exception { JAXRSClientFactoryBean bean=new JAXRSClientFactoryBean(); bean.setAddress("http://bar"); bean.setResourceClass(BookStoreSubresourcesOnly.class); BookStoreSubresourcesOnly store=bean.create(BookStoreSubresourcesOnly.class); BookStoreSubresourcesOnly store2=store.getItself4("4","11","22","33"); assertEquals("http://bar/bookstore/11/22/33/sub2/4",WebClient.client(store2).getCurrentURI().toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testTemplateInRootAppend() throws Exception { JAXRSClientFactoryBean bean=new JAXRSClientFactoryBean(); bean.setAddress("http://bar"); bean.setResourceClass(BookStoreSubresourcesOnly.class); BookStoreSubresourcesOnly store=bean.create(BookStoreSubresourcesOnly.class,1,2,3); BookStoreSubresourcesOnly store2=store.getItself3("id4"); assertEquals("http://bar/bookstore/1/2/3/id4/sub3",WebClient.client(store2).getCurrentURI().toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testTemplateInRootPathInherit() throws Exception { JAXRSClientFactoryBean bean=new JAXRSClientFactoryBean(); bean.setAddress("http://bar"); bean.setResourceClass(BookStoreSubresourcesOnly.class); BookStoreSubresourcesOnly store=bean.create(BookStoreSubresourcesOnly.class,1,2,3); BookStoreSubresourcesOnly store2=store.getItself(); assertEquals("http://bar/bookstore/1/2/3/sub1",WebClient.client(store2).getCurrentURI().toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testTemplateInRootReplace() throws Exception { JAXRSClientFactoryBean bean=new JAXRSClientFactoryBean(); bean.setAddress("http://bar"); bean.setResourceClass(BookStoreSubresourcesOnly.class); BookStoreSubresourcesOnly store=bean.create(BookStoreSubresourcesOnly.class,1,2,3); BookStoreSubresourcesOnly store2=store.getItself2("4","11","33"); assertEquals("http://bar/bookstore/11/2/33/sub2/4",WebClient.client(store2).getCurrentURI().toString()); }

Class: org.apache.cxf.jaxrs.client.WebClientTest

EqualityVerifier 
@Test public void testDoubleAsteriscs(){ URI u=WebClient.create("http://foo").path("**").getCurrentURI(); assertEquals("http://foo/**",u.toString()); }

EqualityVerifier 
@Test public void testBaseCurrentPath(){ assertEquals(URI.create("http://foo"),WebClient.create("http://foo").getBaseURI()); assertEquals(URI.create("http://foo"),WebClient.create("http://foo").getCurrentURI()); }

InternalCallVerifier EqualityVerifier 
@Test public void testBaseCurrentPathAfterChange(){ WebClient wc=WebClient.create(URI.create("http://foo")); wc.path("bar").path("baz").matrix("m1","m1value").query("q1","q1value"); assertEquals(URI.create("http://foo"),wc.getBaseURI()); assertEquals(URI.create("http://foo/bar/baz;m1=m1value?q1=q1value"),wc.getCurrentURI()); }

InternalCallVerifier EqualityVerifier 
@Test public void testPathWithTemplates(){ WebClient wc=WebClient.create(URI.create("http://foo")); assertEquals(URI.create("http://foo"),wc.getBaseURI()); assertEquals(URI.create("http://foo"),wc.getCurrentURI()); wc.path("{bar}/{foo}",1,2); assertEquals(URI.create("http://foo"),wc.getBaseURI()); assertEquals(URI.create("http://foo/1/2"),wc.getCurrentURI()); }

InternalCallVerifier EqualityVerifier 
@Test public void testNewBaseCurrentWebSocketPath(){ WebClient wc=WebClient.create("ws://foo"); assertEquals(URI.create("ws://foo"),wc.getBaseURI()); assertEquals(URI.create("ws://foo"),wc.getCurrentURI()); wc.to("ws://bar",false); assertEquals(URI.create("ws://bar"),wc.getBaseURI()); assertEquals(URI.create("ws://bar"),wc.getCurrentURI()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testHeaders(){ WebClient wc=WebClient.create(URI.create("http://foo")); wc.header("h1","h1value").header("h2","h2value"); assertEquals(1,wc.getHeaders().get("h1").size()); assertEquals("h1value",wc.getHeaders().getFirst("h1")); assertEquals(1,wc.getHeaders().get("h2").size()); assertEquals("h2value",wc.getHeaders().getFirst("h2")); wc.getHeaders().clear(); assertEquals(1,wc.getHeaders().get("h1").size()); assertEquals("h1value",wc.getHeaders().getFirst("h1")); assertEquals(1,wc.getHeaders().get("h2").size()); assertEquals("h2value",wc.getHeaders().getFirst("h2")); wc.reset(); assertTrue(wc.getHeaders().isEmpty()); }

EqualityVerifier 
@Test public void testExistingAsteriscs(){ URI u=WebClient.create("http://foo/*").getCurrentURI(); assertEquals("http://foo/*",u.toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testBack(){ WebClient wc=WebClient.create(URI.create("http://foo")); wc.path("bar").path("baz"); assertEquals(URI.create("http://foo"),wc.getBaseURI()); assertEquals(URI.create("http://foo/bar/baz"),wc.getCurrentURI()); wc.back(false); assertEquals(URI.create("http://foo/bar"),wc.getCurrentURI()); wc.back(false); assertEquals(URI.create("http://foo"),wc.getCurrentURI()); wc.back(false); assertEquals(URI.create("http://foo"),wc.getCurrentURI()); }

InternalCallVerifier EqualityVerifier 
@Test public void testReplacePathAll(){ WebClient wc=WebClient.create(URI.create("http://foo")); wc.path("bar").path("baz"); assertEquals(URI.create("http://foo"),wc.getBaseURI()); assertEquals(URI.create("http://foo/bar/baz"),wc.getCurrentURI()); wc.replacePath("/new"); assertEquals(URI.create("http://foo/new"),wc.getCurrentURI()); }

EqualityVerifier 
@Test public void testEncoding(){ URI u=WebClient.create("http://foo").path("bar+ %2B").matrix("a","value+ ").query("b","bv+ %2B").getCurrentURI(); assertEquals("http://foo/bar+%20%2B;a=value+%20?b=bv%2B+%2B",u.toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testEmptyQuery(){ WebClient wc=WebClient.create("http://foo"); wc.query("_wadl"); assertEquals("http://foo?_wadl",wc.getCurrentURI().toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testForward(){ WebClient wc=WebClient.create("http://foo"); wc.to("http://foo/bar",true); assertEquals(URI.create("http://foo"),wc.getBaseURI()); assertEquals(URI.create("http://foo/bar"),wc.getCurrentURI()); }

InternalCallVerifier EqualityVerifier 
@Test public void testBaseCurrentWebSocketPath(){ WebClient wc=WebClient.create("ws://foo"); assertEquals(URI.create("ws://foo"),wc.getBaseURI()); assertEquals(URI.create("ws://foo"),wc.getCurrentURI()); wc.path("a"); assertEquals(URI.create("ws://foo"),wc.getBaseURI()); assertEquals(URI.create("ws://foo/a"),wc.getCurrentURI()); }

InternalCallVerifier EqualityVerifier 
@Test public void testReplacePathLastSegment(){ WebClient wc=WebClient.create(URI.create("http://foo")); wc.path("bar").path("baz"); assertEquals(URI.create("http://foo"),wc.getBaseURI()); assertEquals(URI.create("http://foo/bar/baz"),wc.getCurrentURI()); wc.replacePath("new"); assertEquals(URI.create("http://foo/bar/new"),wc.getCurrentURI()); }

InternalCallVerifier EqualityVerifier 
@Test public void testFragment(){ WebClient wc=WebClient.create(URI.create("http://foo")); wc.path("bar").path("baz").query("foo","bar").fragment("1"); assertEquals(URI.create("http://foo"),wc.getBaseURI()); assertEquals(URI.create("http://foo/bar/baz?foo=bar#1"),wc.getCurrentURI()); }

InternalCallVerifier EqualityVerifier 
@Test public void testResetQueryAndBack(){ WebClient wc=WebClient.create(URI.create("http://foo")); wc.path("bar").path("baz").query("foo","bar"); assertEquals(URI.create("http://foo"),wc.getBaseURI()); assertEquals(URI.create("http://foo/bar/baz?foo=bar"),wc.getCurrentURI()); wc.resetQuery().back(false); assertEquals(URI.create("http://foo/bar"),wc.getCurrentURI()); }

EqualityVerifier 
@Test public void testAddressNotEncoded(){ URI u=WebClient.create("http://localhost/somepath ").getCurrentURI(); assertEquals("http://localhost/somepath%20",u.toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testReplaceQuery(){ WebClient wc=WebClient.create(URI.create("http://foo")); wc.path("bar").path("baz").query("foo","bar"); assertEquals(URI.create("http://foo"),wc.getBaseURI()); assertEquals(URI.create("http://foo/bar/baz?foo=bar"),wc.getCurrentURI()); wc.replaceQuery("foo1=bar1"); assertEquals(URI.create("http://foo/bar/baz?foo1=bar1"),wc.getCurrentURI()); }

InternalCallVerifier EqualityVerifier 
@Test public void testRemoveHeader(){ WebClient wc=WebClient.create("http://foo").header("a","b"); assertEquals(1,wc.getHeaders().size()); assertEquals("b",wc.getHeaders().getFirst("a")); wc.replaceHeader("a",null); assertEquals(0,wc.getHeaders().size()); }

InternalCallVerifier EqualityVerifier 
@Test public void testWebClientParamConverter(){ WebClient wc=WebClient.create("http://foo",Collections.singletonList(new ParamConverterProviderImpl())); wc.path(new ComplexObject()); wc.query("param",new ComplexObject(),new ComplexObject()); assertEquals("http://foo/complex?param=complex¶m=complex",wc.getCurrentURI().toString()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testBaseCurrentPathAfterCopy(){ WebClient wc=WebClient.create(URI.create("http://foo")); wc.path("bar").path("baz").matrix("m1","m1value").query("q1","q1value"); WebClient wc1=WebClient.fromClient(wc); assertEquals(URI.create("http://foo/bar/baz;m1=m1value?q1=q1value"),wc1.getBaseURI()); assertEquals(URI.create("http://foo/bar/baz;m1=m1value?q1=q1value"),wc1.getCurrentURI()); }

InternalCallVerifier EqualityVerifier 
@Test public void testReplaceHeader(){ WebClient wc=WebClient.create("http://foo").header("a","b"); assertEquals(1,wc.getHeaders().size()); assertEquals("b",wc.getHeaders().getFirst("a")); wc.replaceHeader("a","c"); assertEquals(1,wc.getHeaders().size()); assertEquals("c",wc.getHeaders().getFirst("a")); }

InternalCallVerifier EqualityVerifier 
@Test public void testNewBaseCurrentPath(){ WebClient wc=WebClient.create("http://foo"); assertEquals(URI.create("http://foo"),wc.getBaseURI()); assertEquals(URI.create("http://foo"),wc.getCurrentURI()); wc.to("http://bar",false); assertEquals(URI.create("http://bar"),wc.getBaseURI()); assertEquals(URI.create("http://bar"),wc.getCurrentURI()); }

InternalCallVerifier EqualityVerifier 
@Test public void testBackFast(){ WebClient wc=WebClient.create(URI.create("http://foo")); wc.path("bar").path("baz").matrix("m1","m1value"); assertEquals(URI.create("http://foo"),wc.getBaseURI()); assertEquals(URI.create("http://foo/bar/baz;m1=m1value"),wc.getCurrentURI()); wc.back(true); assertEquals(URI.create("http://foo"),wc.getCurrentURI()); }

InternalCallVerifier EqualityVerifier 
@Test public void testCompositePath(){ WebClient wc=WebClient.create("http://foo"); wc.path("/bar/baz/"); assertEquals(URI.create("http://foo"),wc.getBaseURI()); assertEquals(URI.create("http://foo/bar/baz/"),wc.getCurrentURI()); }

EqualityVerifier 
@Test public void testAsteriscs(){ URI u=WebClient.create("http://foo").path("*").getCurrentURI(); assertEquals("http://foo/*",u.toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testReplaceQueryParam(){ WebClient wc=WebClient.create(URI.create("http://foo")); wc.path("bar").path("baz").query("foo","bar").query("foo1","bar1"); assertEquals(URI.create("http://foo"),wc.getBaseURI()); assertEquals(URI.create("http://foo/bar/baz?foo=bar&foo1=bar1"),wc.getCurrentURI()); wc.replaceQueryParam("foo1","baz"); assertEquals(URI.create("http://foo/bar/baz?foo=bar&foo1=baz"),wc.getCurrentURI()); }

Class: org.apache.cxf.jaxrs.client.cache.ClientCacheTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetTimeStringAsInputStreamAndString() throws Exception { CacheControlFeature feature=new CacheControlFeature(); try { feature.setCacheResponseInputStream(true); final WebTarget base=ClientBuilder.newBuilder().register(feature).build().target(ADDRESS); final Invocation.Builder cached=base.request("text/plain").header(HttpHeaders.CACHE_CONTROL,"public"); final Response r=cached.get(); assertEquals(Response.Status.OK.getStatusCode(),r.getStatus()); InputStream is=r.readEntity(InputStream.class); final String r1=IOUtils.readStringFromStream(is); waitABit(); final String r2=cached.get().readEntity(String.class); assertEquals(r1,r2); } finally { feature.close(); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetTimeStringAsInputStream() throws Exception { CacheControlFeature feature=new CacheControlFeature(); try { final WebTarget base=ClientBuilder.newBuilder().register(feature).build().target(ADDRESS); final Invocation.Builder cached=base.request("text/plain").header(HttpHeaders.CACHE_CONTROL,"public"); final Response r=cached.get(); assertEquals(Response.Status.OK.getStatusCode(),r.getStatus()); InputStream is=r.readEntity(InputStream.class); final String r1=IOUtils.readStringFromStream(is); waitABit(); is=cached.get().readEntity(InputStream.class); final String r2=IOUtils.readStringFromStream(is); assertEquals(r1,r2); } finally { feature.close(); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetTimeString(){ CacheControlFeature feature=new CacheControlFeature(); try { final WebTarget base=ClientBuilder.newBuilder().register(feature).build().target(ADDRESS); final Invocation.Builder cached=base.request("text/plain").header(HttpHeaders.CACHE_CONTROL,"public"); final Response r=cached.get(); assertEquals(Response.Status.OK.getStatusCode(),r.getStatus()); final String r1=r.readEntity(String.class); waitABit(); assertEquals(r1,cached.get().readEntity(String.class)); } finally { feature.close(); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetJaxbBookCache(){ CacheControlFeature feature=new CacheControlFeature(); try { final WebTarget base=ClientBuilder.newBuilder().register(feature).build().target(ADDRESS); final Invocation.Builder cached=setAsLocal(base.request("application/xml")).header(HttpHeaders.CACHE_CONTROL,"public"); final Response r=cached.get(); assertEquals(Response.Status.OK.getStatusCode(),r.getStatus()); final Book b1=r.readEntity(Book.class); assertEquals("JCache",b1.getName()); assertNotNull(b1.getId()); waitABit(); assertEquals(b1,cached.get().readEntity(Book.class)); } finally { feature.close(); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetTimeStringAsStringAndInputStream() throws Exception { CacheControlFeature feature=new CacheControlFeature(); try { feature.setCacheResponseInputStream(true); final WebTarget base=ClientBuilder.newBuilder().register(feature).build().target(ADDRESS); final Invocation.Builder cached=base.request("text/plain").header(HttpHeaders.CACHE_CONTROL,"public"); final Response r=cached.get(); assertEquals(Response.Status.OK.getStatusCode(),r.getStatus()); final String r1=r.readEntity(String.class); waitABit(); InputStream is=cached.get().readEntity(InputStream.class); final String r2=IOUtils.readStringFromStream(is); assertEquals(r1,r2); } finally { feature.close(); } }

Class: org.apache.cxf.jaxrs.client.spring.JAXRSClientFactoryBeanTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testClients() throws Exception { ClassPathXmlApplicationContext ctx=new ClassPathXmlApplicationContext(new String[]{"/org/apache/cxf/jaxrs/client/spring/clients.xml"}); Object bean=ctx.getBean("client1.proxyFactory"); assertNotNull(bean); bean=ctx.getBean("setHeaderClient.proxyFactory"); assertNotNull(bean); JAXRSClientFactoryBean cfb=(JAXRSClientFactoryBean)bean; assertNotNull(cfb.getHeaders()); assertEquals("Get a wrong map size",cfb.getHeaders().size(),1); assertEquals("Get a wrong username",cfb.getUsername(),"username"); assertEquals("Get a wrong password",cfb.getPassword(),"password"); QName serviceQName=new QName("http://books.com","BookService"); assertEquals(serviceQName,cfb.getServiceName()); assertEquals(serviceQName,cfb.getServiceFactory().getServiceName()); bean=ctx.getBean("ModelClient.proxyFactory"); assertNotNull(bean); cfb=(JAXRSClientFactoryBean)bean; assertNotNull(cfb.getHeaders()); assertEquals("Get a wrong map size",cfb.getHeaders().size(),1); assertEquals("Get a wrong username",cfb.getUsername(),"username"); assertEquals("Get a wrong password",cfb.getPassword(),"password"); ctx.close(); }

Class: org.apache.cxf.jaxrs.ext.MessageContextImplTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetProperty(){ Message m=new MessageImpl(); m.put("a","b"); MessageContext mc=new MessageContextImpl(m); assertEquals("b",mc.get("a")); assertNull(mc.get("b")); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetPropertyFromOtherMessage(){ Message m1=new MessageImpl(); Message m2=new MessageImpl(); m2.put("a","b"); Exchange ex=new ExchangeImpl(); ex.setInMessage(m1); ex.setOutMessage(m2); MessageContext mc=new MessageContextImpl(m1); assertEquals("b",mc.get("a")); assertNull(mc.get("b")); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetPropertyFromExchange(){ Message m=new MessageImpl(); Exchange ex=new ExchangeImpl(); ex.put("a","b"); ex.setInMessage(m); MessageContext mc=new MessageContextImpl(m); assertEquals("b",mc.get("a")); assertNull(mc.get("b")); }

Class: org.apache.cxf.jaxrs.ext.form.FormTest

EqualityVerifier 
@Test public void testToString(){ Form form=new Form().param("a","b").param("c","d"); assertEquals("a=b&c=d",FormUtils.formToString(form)); }

Class: org.apache.cxf.jaxrs.ext.multipart.AttachmentTest

EqualityVerifier 
@Test public void testGetHeaders(){ Attachment a=createAttachment("p1"); assertEquals("bar",a.getHeader("foo")); }

Class: org.apache.cxf.jaxrs.ext.multipart.ContentDispositionTest

InternalCallVerifier EqualityVerifier 
@Test public void testContentDispositionWithQuotes(){ ContentDisposition cd=new ContentDisposition(" attachment ; bar=\"foo.txt\" ; baz = baz1"); assertEquals("attachment",cd.getType()); assertEquals("foo.txt",cd.getParameter("bar")); assertEquals("baz1",cd.getParameter("baz")); }

InternalCallVerifier EqualityVerifier 
@Test public void testContentDispositionWithQuotesAndSemicolon(){ ContentDisposition cd=new ContentDisposition(" attachment ; bar=\"foo;txt\" ; baz = baz1"); assertEquals("attachment",cd.getType()); assertEquals("foo;txt",cd.getParameter("bar")); assertEquals("baz1",cd.getParameter("baz")); }

InternalCallVerifier EqualityVerifier 
@Test public void testContentDisposition(){ ContentDisposition cd=new ContentDisposition(" attachment ; bar=foo ; baz = baz1"); assertEquals("attachment",cd.getType()); assertEquals("foo",cd.getParameter("bar")); assertEquals("baz1",cd.getParameter("baz")); }

Class: org.apache.cxf.jaxrs.ext.multipart.MultipartBodyTest

InternalCallVerifier EqualityVerifier 
@Test public void testGetAttachments(){ List atts=new ArrayList(); atts.add(createAttachment("p1")); atts.add(createAttachment("p2")); MultipartBody b=new MultipartBody(atts); assertEquals(atts,b.getAllAttachments()); assertEquals(atts.get(0),b.getRootAttachment()); assertEquals(atts.get(1),b.getChildAttachments().get(0)); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetAttachmentsById(){ List atts=new ArrayList(); atts.add(createAttachment("p1")); atts.add(createAttachment("p2")); MultipartBody b=new MultipartBody(atts); assertEquals(atts.get(0),b.getAttachment("p1")); assertEquals(atts.get(1),b.getAttachment("p2")); assertNull(b.getAttachment("p3")); }

Class: org.apache.cxf.jaxrs.ext.search.BeanspectorTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testSimpleBean() throws SearchParseException { Beanspector bean=new Beanspector(new SimpleBean()); Set getters=bean.getGettersNames(); assertEquals(3,getters.size()); assertTrue(getters.contains("class")); assertTrue(getters.contains("a")); assertTrue(getters.contains("promised")); Set setters=bean.getSettersNames(); assertEquals(1,setters.size()); assertTrue(getters.contains("a")); }

Class: org.apache.cxf.jaxrs.ext.search.SearchContextImplTest

InternalCallVerifier EqualityVerifier 
@Test public void testPlainQuery5(){ Message m=new MessageImpl(); m.put("search.use.plain.queries",true); m.put(Message.QUERY_STRING,"aFrom=1&aTill=3"); String exp=new SearchContextImpl(m).getSearchExpression(); assertEquals("(a=ge=1;a=le=3)",exp); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSingleEquals(){ Message m=new MessageImpl(); m.put(Message.QUERY_STRING,"_s=name=CXF"); m.put("fiql.support.single.equals.operator","true"); SearchContext context=new SearchContextImpl(m); SearchCondition sc=context.getCondition(SearchBean.class); assertNotNull(sc); PrimitiveStatement ps=sc.getStatement(); assertNotNull(ps); assertEquals("name",ps.getProperty()); assertEquals("CXF",ps.getValue()); assertEquals(ConditionType.EQUALS,ps.getCondition()); assertEquals(String.class,ps.getValueType()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testPrimitiveStatementSearchBean(){ Message m=new MessageImpl(); m.put(Message.QUERY_STRING,"_s=name==CXF"); SearchContext context=new SearchContextImpl(m); SearchCondition sc=context.getCondition(SearchBean.class); assertNotNull(sc); PrimitiveStatement ps=sc.getStatement(); assertNotNull(ps); assertEquals("name",ps.getProperty()); assertEquals("CXF",ps.getValue()); assertEquals(ConditionType.EQUALS,ps.getCondition()); assertEquals(String.class,ps.getValueType()); }

InternalCallVerifier EqualityVerifier 
@Test public void testPlainQuery2(){ Message m=new MessageImpl(); m.put("search.use.plain.queries",true); m.put(Message.QUERY_STRING,"a=b&a=b1"); String exp=new SearchContextImpl(m).getSearchExpression(); assertEquals("(a==b,a==b1)",exp); }

InternalCallVerifier EqualityVerifier 
@Test public void testPlainQuery1(){ Message m=new MessageImpl(); m.put("search.use.plain.queries",true); m.put(Message.QUERY_STRING,"a=b"); String exp=new SearchContextImpl(m).getSearchExpression(); assertEquals("a==b",exp); }

InternalCallVerifier EqualityVerifier 
@Test public void testPlainQuery4(){ Message m=new MessageImpl(); m.put("search.use.plain.queries",true); m.put(Message.QUERY_STRING,"a=b&a=b2&c=d&f=g"); String exp=new SearchContextImpl(m).getSearchExpression(); assertEquals("((a==b,a==b2);c==d;f==g)",exp); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testPrimitiveStatementSearchBeanComlexName(){ Message m=new MessageImpl(); m.put(Message.QUERY_STRING,"_s=complex.name==CXF"); SearchContext context=new SearchContextImpl(m); SearchCondition sc=context.getCondition(SearchBean.class); assertNotNull(sc); PrimitiveStatement ps=sc.getStatement(); assertNotNull(ps); assertEquals("complex.name",ps.getProperty()); assertEquals("CXF",ps.getValue()); assertEquals(ConditionType.EQUALS,ps.getCondition()); assertEquals(String.class,ps.getValueType()); }

InternalCallVerifier EqualityVerifier 
@Test public void testPlainQuery3(){ Message m=new MessageImpl(); m.put("search.use.plain.queries",true); m.put(Message.QUERY_STRING,"a=b&c=d"); String exp=new SearchContextImpl(m).getSearchExpression(); assertEquals("(a==b;c==d)",exp); }

Class: org.apache.cxf.jaxrs.ext.search.SearchUtilsTest

EqualityVerifier 
@Test public void testSqlWildcardString5(){ assertEquals("%",SearchUtils.toSqlWildcardString("*",false)); }

EqualityVerifier 
@Test public void testSqlWildcardStringAlways(){ assertEquals("%abc%",SearchUtils.toSqlWildcardString("abc",true)); }

EqualityVerifier 
@Test public void testSqlWildcardString2(){ assertEquals("%abc",SearchUtils.toSqlWildcardString("*abc",false)); }

EqualityVerifier 
@Test public void testSqlWildcardString3(){ assertEquals("abc%",SearchUtils.toSqlWildcardString("abc*",false)); }

EqualityVerifier 
@Test public void testSqlWildcardString4(){ assertEquals("%abc%",SearchUtils.toSqlWildcardString("*abc*",false)); }

EqualityVerifier 
@Test public void testSqlWildcardString(){ assertEquals("abc",SearchUtils.toSqlWildcardString("abc",false)); }

Class: org.apache.cxf.jaxrs.ext.search.SimpleSearchConditionTest

EqualityVerifier 
@Test public void testGetConditions(){ assertEquals(cGt.getSearchConditions(),null); }

EqualityVerifier 
@Test public void testGetCondition(){ assertEquals(cLeq.getCondition(),attr); }

EqualityVerifier 
@Test public void testGetConditionType(){ assertEquals(cEq.getConditionType(),ConditionType.EQUALS); assertEquals(cLt.getConditionType(),ConditionType.LESS_THAN); }

APIUtilityVerifier EqualityVerifier 
@Test public void testFindAll(){ List inputs=Arrays.asList(attr,attrGreater,attrLesser); List found=Arrays.asList(attr,attrGreater); assertEquals(found,cGeq.findAll(inputs)); }

Class: org.apache.cxf.jaxrs.ext.search.client.FiqlSearchConditionBuilderTest

InternalCallVerifier EqualityVerifier 
@Test public void testLessOrEqualToNumberDouble(){ String ret=b.is("foo").lessOrEqualTo(0.0).query(); assertEquals("foo=le=0.0",ret); }

InternalCallVerifier EqualityVerifier 
@Test public void testComplex1(){ String ret=b.is("foo").equalTo(123.4).or().and(b.is("bar").equalTo("asadf*"),b.is("baz").lessThan(20)).query(); assertEquals("foo==123.4,(bar==asadf*;baz=lt=20)",ret); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGreaterOrEqualToDuration() throws DatatypeConfigurationException { Duration d=DatatypeFactory.newInstance().newDuration(false,0,0,1,12,0,0); String ret=b.is("foo").notBefore(d).query(); assertEquals("foo=ge=-P0Y0M1DT12H0M0S",ret); }

InternalCallVerifier EqualityVerifier 
@Test public void testEqualToString(){ String ret=b.is("foo").equalTo("literalOrPattern*").query(); assertEquals("foo==literalOrPattern*",ret); }

InternalCallVerifier EqualityVerifier 
@Test public void testLessOrEqualToString(){ String ret=b.is("foo").lexicalNotAfter("abc").query(); assertEquals("foo=le=abc",ret); }

InternalCallVerifier EqualityVerifier 
@Test public void testMultipleOrShortcutWithAnd2(){ String ret=b.is("foo").equalTo(123.4,137.8).or("n").equalTo("n1").and("bar").equalTo("baz").query(); assertEquals("(foo==123.4,foo==137.8,n==n1);bar==baz",ret); }

InternalCallVerifier EqualityVerifier 
@Test public void testLessThanString(){ String ret=b.is("foo").lexicalBefore("abc").query(); assertEquals("foo=lt=abc",ret); }

InternalCallVerifier EqualityVerifier 
@Test public void testEqualToNumberCondition(){ String ret=b.is("foo").comparesTo(ConditionType.LESS_THAN,123.5).query(); assertEquals("foo=lt=123.5",ret); }

InternalCallVerifier EqualityVerifier 
@Test public void testGreaterThanLong(){ String ret=b.is("foo").greaterThan(25).query(); assertEquals("foo=gt=25",ret); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testLessThanDuration() throws DatatypeConfigurationException { Duration d=DatatypeFactory.newInstance().newDuration(false,0,0,1,12,0,0); String ret=b.is("foo").before(d).query(); assertEquals("foo=lt=-P0Y0M1DT12H0M0S",ret); }

InternalCallVerifier EqualityVerifier 
@Test public void testGreaterThanNumberDouble(){ String ret=b.is("foo").greaterThan(25.0).query(); assertEquals("foo=gt=25.0",ret); }

InternalCallVerifier EqualityVerifier 
@Test public void testGreaterOrEqualToString(){ String ret=b.is("foo").lexicalNotBefore("abc").query(); assertEquals("foo=ge=abc",ret); }

InternalCallVerifier EqualityVerifier 
@Test public void testNotEqualToString(){ String ret=b.is("foo").notEqualTo("literalOrPattern*").query(); assertEquals("foo!=literalOrPattern*",ret); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testLessOrEqualToDate() throws ParseException { Date d=parseDate(SearchUtils.DEFAULT_DATE_FORMAT,"2011-03-02"); String ret=b.is("foo").notAfter(d).query(); assertEquals("foo=le=2011-03-02",ret); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testLessThanDate() throws ParseException { Date d=parseDate(SearchUtils.DEFAULT_DATE_FORMAT,"2011-03-02"); String ret=b.is("foo").before(d).query(); assertEquals("foo=lt=2011-03-02",ret); }

InternalCallVerifier EqualityVerifier 
@Test public void testAndSimpleShortcut(){ String ret=b.is("foo").greaterThan(20).and("bar").equalTo("plonk").query(); assertEquals("foo=gt=20;bar==plonk",ret); }

InternalCallVerifier EqualityVerifier 
@Test public void testLessThanNumber(){ String ret=b.is("foo").lessThan(25.333).query(); assertEquals("foo=lt=25.333",ret); }

InternalCallVerifier EqualityVerifier 
@Test public void testMultipleOrShortcut(){ String ret=b.is("foo").equalTo(123.4,137.8).query(); assertEquals("foo==123.4,foo==137.8",ret); }

InternalCallVerifier EqualityVerifier 
@Test public void testEqualToNumber(){ String ret=b.is("foo").equalTo(123.5).query(); assertEquals("foo==123.5",ret); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGreaterThanDate() throws ParseException { Date d=parseDate(SearchUtils.DEFAULT_DATE_FORMAT,"2011-03-02"); String ret=b.is("foo").after(d).query(); assertEquals("foo=gt=2011-03-02",ret); }

InternalCallVerifier EqualityVerifier 
@Test public void testAndComplex(){ String ret=b.and(b.is("foo").equalTo("aaa"),b.is("bar").equalTo("bbb")).query(); assertEquals("(foo==aaa;bar==bbb)",ret); }

InternalCallVerifier EqualityVerifier 
@Test public void testOrSimpleShortcut(){ String ret=b.is("foo").greaterThan(20).or("foo").lessThan(10).query(); assertEquals("foo=gt=20,foo=lt=10",ret); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGreaterThanDuration() throws DatatypeConfigurationException { Duration d=DatatypeFactory.newInstance().newDuration(false,0,0,1,12,0,0); String ret=b.is("foo").after(d).query(); assertEquals("foo=gt=-P0Y0M1DT12H0M0S",ret); }

InternalCallVerifier EqualityVerifier 
@Test public void testMultipleOrShortcutWithAnd(){ String ret=b.is("foo").equalTo(123.4,137.8).and("bar").equalTo("baz").query(); assertEquals("(foo==123.4,foo==137.8);bar==baz",ret); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testEqualToDateWithCustomFormat() throws ParseException { Map props=new HashMap(); props.put(SearchUtils.DATE_FORMAT_PROPERTY,"yyyy-MM-dd'T'HH:mm:ss"); props.put(SearchUtils.TIMEZONE_SUPPORT_PROPERTY,"false"); Date d=parseDate("yyyy-MM-dd HH:mm Z","2011-03-01 12:34 +0000"); FiqlSearchConditionBuilder bCustom=new FiqlSearchConditionBuilder(props); String ret=bCustom.is("foo").equalTo(d).query(); assertEquals("foo==2011-03-01T12:34:00",ret); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testNotEqualToDuration() throws ParseException, DatatypeConfigurationException { Duration d=DatatypeFactory.newInstance().newDuration(false,0,0,1,12,0,0); String ret=b.is("foo").notEqualTo(d).query(); assertEquals("foo!=-P0Y0M1DT12H0M0S",ret); }

InternalCallVerifier EqualityVerifier 
@Test public void testAndSimple(){ String ret=b.is("foo").greaterThan(20).and().is("bar").equalTo("plonk").query(); assertEquals("foo=gt=20;bar==plonk",ret); }

InternalCallVerifier EqualityVerifier 
@Test public void testOrComplex(){ String ret=b.or(b.is("foo").equalTo("aaa"),b.is("bar").equalTo("bbb")).query(); assertEquals("(foo==aaa,bar==bbb)",ret); }

InternalCallVerifier EqualityVerifier 
@Test public void testLessOrEqualToNumberLong(){ String ret=b.is("foo").lessOrEqualTo(0).query(); assertEquals("foo=le=0",ret); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testEqualToDuration() throws ParseException, DatatypeConfigurationException { Duration d=DatatypeFactory.newInstance().newDuration(false,0,0,1,12,0,0); String ret=b.is("foo").equalTo(d).query(); assertEquals("foo==-P0Y0M1DT12H0M0S",ret); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testLessOrEqualToDuration() throws DatatypeConfigurationException { Duration d=DatatypeFactory.newInstance().newDuration(false,0,0,1,12,0,0); String ret=b.is("foo").notAfter(d).query(); assertEquals("foo=le=-P0Y0M1DT12H0M0S",ret); }

InternalCallVerifier EqualityVerifier 
@Test public void testOrAndImplicitWrap(){ String ret=b.is("foo").equalTo(1,2).and("bar").equalTo("baz").query(); assertEquals("(foo==1,foo==2);bar==baz",ret); }

InternalCallVerifier EqualityVerifier 
@Test public void testNotEqualToNumber(){ String ret=b.is("foo").notEqualTo(123.5).query(); assertEquals("foo!=123.5",ret); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGreaterOrEqualToDate() throws ParseException { Date d=parseDate(SearchUtils.DEFAULT_DATE_FORMAT,"2011-03-02"); String ret=b.is("foo").notBefore(d).query(); assertEquals("foo=ge=2011-03-02",ret); }

InternalCallVerifier EqualityVerifier 
@Test public void testGreaterOrEqualToNumberLong(){ String ret=b.is("foo").greaterOrEqualTo(-5).query(); assertEquals("foo=ge=-5",ret); }

InternalCallVerifier EqualityVerifier 
@Test public void testGreaterThanString(){ String ret=b.is("foo").lexicalAfter("abc").query(); assertEquals("foo=gt=abc",ret); }

InternalCallVerifier EqualityVerifier 
@Test public void testOrSimple(){ String ret=b.is("foo").greaterThan(20).or().is("foo").lessThan(10).query(); assertEquals("foo=gt=20,foo=lt=10",ret); }

InternalCallVerifier EqualityVerifier 
@Test public void testGreaterOrEqualToNumberDouble(){ String ret=b.is("foo").greaterOrEqualTo(-5.0).query(); assertEquals("foo=ge=-5.0",ret); }

InternalCallVerifier EqualityVerifier 
@Test public void testComplex2(){ String ret=b.is("foo").equalTo(123L).or().is("foo").equalTo("null").and().or(b.is("bar").equalTo("asadf*"),b.is("baz").lessThan(20).and().or(b.is("sub1").equalTo(0L),b.is("sub2").equalTo(0L))).query(); assertEquals("foo==123,foo==null;(bar==asadf*,baz=lt=20;(sub1==0,sub2==0))",ret); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testNotEqualToDateDefault() throws ParseException { Date d=parseDate(SearchUtils.DEFAULT_DATE_FORMAT,"2011-03-01"); String ret=b.is("foo").notEqualTo(d).query(); assertEquals("foo!=2011-03-01",ret); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testEqualToDateDefault() throws ParseException { Date d=parseDate(SearchUtils.DEFAULT_DATE_FORMAT,"2011-03-01"); String ret=b.is("foo").equalTo(d).query(); assertEquals("foo==2011-03-01",ret); }

EqualityVerifier 
@Test public void testEmptyBuild(){ assertEquals("",b.query()); }

Class: org.apache.cxf.jaxrs.ext.search.fiql.FiqlParserTest

InternalCallVerifier EqualityVerifier 
@Test public void testMultipleLists() throws SearchParseException { FiqlParser jobParser=new FiqlParser(Job.class,Collections.emptyMap(),Collections.singletonMap("itemName","tasks.items.itemName")); SearchCondition jobCondition=jobParser.parse("itemName==myitem"); Job job=jobCondition.getCondition(); assertEquals("myitem",job.getTasks().get(0).getItems().get(0).getItemName()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testParseComplex2() throws SearchParseException { SearchCondition filter=parser.parse("name==ami*,level=gt=10"); assertEquals(ConditionType.OR,filter.getConditionType()); List> conditions=filter.getSearchConditions(); assertEquals(2,conditions.size()); PrimitiveStatement st1=conditions.get(0).getStatement(); PrimitiveStatement st2=conditions.get(1).getStatement(); assertTrue((ConditionType.EQUALS.equals(st1.getCondition()) && ConditionType.GREATER_THAN.equals(st2.getCondition())) || (ConditionType.EQUALS.equals(st2.getCondition()) && ConditionType.GREATER_THAN.equals(st1.getCondition()))); assertTrue(filter.isMet(new Condition("ami",0,new Date()))); assertTrue(filter.isMet(new Condition("foo",20,null))); assertFalse(filter.isMet(new Condition("foo",0,null))); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testParseComplex1() throws SearchParseException { SearchCondition filter=parser.parse("name==ami*;level=gt=10"); assertEquals(ConditionType.AND,filter.getConditionType()); List> conditions=filter.getSearchConditions(); assertEquals(2,conditions.size()); PrimitiveStatement st1=conditions.get(0).getStatement(); PrimitiveStatement st2=conditions.get(1).getStatement(); assertTrue((ConditionType.EQUALS.equals(st1.getCondition()) && ConditionType.GREATER_THAN.equals(st2.getCondition())) || (ConditionType.EQUALS.equals(st2.getCondition()) && ConditionType.GREATER_THAN.equals(st1.getCondition()))); assertTrue(filter.isMet(new Condition("amichalec",12,new Date()))); assertTrue(filter.isMet(new Condition("ami",12,new Date()))); assertFalse(filter.isMet(new Condition("ami",8,null))); assertFalse(filter.isMet(new Condition("am",20,null))); }

Class: org.apache.cxf.jaxrs.ext.search.hbase.HBaseVisitorTest

IterativeVerifier InternalCallVerifier EqualityVerifier IgnoredMethod HybridVerifier 
@Test @Ignore("Enable as soon as it is understood how to run HBase tests in process") public void testScanWithFilterVisitor() throws Exception { Scan scan=new Scan(); SearchCondition sc=new FiqlParser(SearchBean.class).parse("name==CXF"); HBaseQueryVisitor visitor=new HBaseQueryVisitor("book"); sc.accept(visitor); Filter filter=visitor.getQuery(); scan.setFilter(filter); ResultScanner rs=table.getScanner(scan); try { int count=0; for (Result r=rs.next(); r != null; r=rs.next()) { assertEquals("row2",new String(r.getRow())); assertEquals("CXF",new String(r.getValue(BOOK_FAMILY,NAME_QUALIFIER))); count++; } assertEquals(1,count); } finally { rs.close(); } }

Class: org.apache.cxf.jaxrs.ext.search.jpa.JPALanguageVisitorTest

EqualityVerifier 
@Test public void testSimpleQuery() throws Exception { SearchCondition filter=new FiqlParser(Book.class).parse("id=lt=10"); JPALanguageVisitor jpa=new JPALanguageVisitor(Book.class); filter.accept(jpa); assertEquals("SELECT t FROM Book t WHERE t.id < '10'",jpa.getQuery()); }

Class: org.apache.cxf.jaxrs.ext.search.jpa.JPATypedQueryVisitorFiqlTest

EqualityVerifier 
@Test public void testQueryCollection2() throws Exception { List books=queryBooks("reviews.book.id==10"); assertEquals(1,books.size()); }

EqualityVerifier 
@Test public void testOrQueryNoMatch() throws Exception { List books=queryBooks("id==7,id==5"); assertEquals(0,books.size()); }

EqualityVerifier 
@Test public void testQueryCollectionSize2() throws Exception { List books=queryBooks("reviews.authors=gt=0"); assertEquals(3,books.size()); }

EqualityVerifier 
@Test public void testNumberOfReviewAuthors2() throws Exception { List books=queryBooks("count(reviews.authors)=gt=3"); assertEquals(0,books.size()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testEqualsAddressQuery2() throws Exception { List books=queryBooks("street==Street1",null,Collections.singletonMap("street","address.street")); assertEquals(1,books.size()); Book book=books.get(0); assertTrue(9 == book.getId()); assertEquals("Street1",book.getAddress().getStreet()); }

EqualityVerifier 
@Test public void testNumberOfReviews2() throws Exception { List books=queryBooks("reviews=gt=3"); assertEquals(0,books.size()); }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testAndQuery() throws Exception { List books=queryBooks("id==10;bookTitle==num10"); assertEquals(1,books.size()); assertTrue(10 == books.get(0).getId() && "num10".equals(books.get(0).getBookTitle())); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testEqualsAddressQuery3() throws Exception { Map beanPropertiesMap=new HashMap(); beanPropertiesMap.put("street","address.street"); beanPropertiesMap.put("housenum","address.houseNumber"); List books=queryBooks("street==Street2;housenum=lt=5",null,beanPropertiesMap); assertEquals(1,books.size()); Book book=books.get(0); assertTrue(10 == book.getId()); assertEquals("Street2",book.getAddress().getStreet()); }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testGreaterEqualQuery() throws Exception { List books=queryBooks("id=ge=10"); assertEquals(2,books.size()); assertTrue(10 == books.get(0).getId() && 11 == books.get(1).getId() || 11 == books.get(0).getId() && 10 == books.get(1).getId()); }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testEqualsQuery() throws Exception { List books=queryBooks("id==10"); assertEquals(1,books.size()); assertTrue(10 == books.get(0).getId()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testEqualsAddressQuery4() throws Exception { Map beanPropertiesMap=new HashMap(); beanPropertiesMap.put("street","address.street"); List books=queryBooks("street==Str*t*",null,beanPropertiesMap); assertEquals(3,books.size()); }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testGreaterQuery() throws Exception { List books=queryBooks("id=gt=10"); assertEquals(1,books.size()); assertTrue(11 == books.get(0).getId()); }

EqualityVerifier 
@Test public void testNumberOfReviews() throws Exception { List books=queryBooks("reviews=gt=0"); assertEquals(3,books.size()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testEqualsOwnerNameQuery2() throws Exception { List books=queryBooks("ownerInfo.name==Fred"); assertEquals(1,books.size()); Book book=books.get(0); assertEquals("Fred",book.getOwnerInfo().getName().getName()); }

EqualityVerifier 
@Test public void testEqualsCriteriaQueryCount() throws Exception { assertEquals(1L,criteriaQueryBooksCount("id==10")); }

APIUtilityVerifier EqualityVerifier 
@Test public void testEqualsAddressQuery5() throws Exception { Map beanPropertiesMap=new HashMap(); beanPropertiesMap.put("street","address.street"); List books=queryBooks("street==Street&'3",null,beanPropertiesMap); assertEquals(1,books.size()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testEqualsOwnerNameQuery3() throws Exception { List books=queryBooks("ownerName==Fred",null,Collections.singletonMap("ownerName","ownerInfo.name.name")); assertEquals(1,books.size()); Book book=books.get(0); assertEquals("Fred",book.getOwnerInfo().getName().getName()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testFindBookInTownLibrary() throws Exception { List books=queryBooks("libAddress==town;bookTitle==num10",null,Collections.singletonMap("libAddress","library.address")); assertEquals(1,books.size()); Book book=books.get(0); assertEquals("Barry",book.getOwnerInfo().getName().getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testEqualsCriteriaQueryTuple() throws Exception { List books=criteriaQueryBooksTuple("id==10"); assertEquals(1,books.size()); Tuple tuple=books.get(0); int tupleId=tuple.get("id",Integer.class); assertEquals(10,tupleId); }

EqualityVerifier 
@Test public void testOrderByAsc() throws Exception { List books=criteriaQueryBooksOrderBy("reviews=gt=0",true); assertEquals(3,books.size()); assertEquals(9,books.get(0).getId()); assertEquals(10,books.get(1).getId()); assertEquals(11,books.get(2).getId()); }

EqualityVerifier 
@Test public void testGetLibraryBook() throws Exception { List books=queryBooks("library.books.bookTitle==num10"); assertEquals(3,books.size()); }

EqualityVerifier 
@Test public void testNumberOfAuthors2() throws Exception { List books=queryBooks("count(authors)=gt=3"); assertEquals(0,books.size()); }

EqualityVerifier 
@Test public void testNumberOfAuthors() throws Exception { List books=queryBooks("count(authors)=gt=0"); assertEquals(3,books.size()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testEqualsAddressQuery() throws Exception { List books=queryBooks("address==Street1",Collections.singletonMap("address","address.street")); assertEquals(1,books.size()); Book book=books.get(0); assertTrue(9 == book.getId()); assertEquals("Street1",book.getAddress().getStreet()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testEqualsOwnerBirthDate() throws Exception { List books=queryBooks("ownerbdate==2000-01-01",null,Collections.singletonMap("ownerbdate","ownerInfo.dateOfBirth")); assertEquals(1,books.size()); Book book=books.get(0); assertEquals("Fred",book.getOwnerInfo().getName().getName()); Date d=parseDate("2000-01-01"); assertEquals("Fred",book.getOwnerInfo().getName().getName()); assertEquals(d,book.getOwnerInfo().getDateOfBirth()); }

EqualityVerifier 
@Test public void testQueryCollection3() throws Exception { List books=queryBooks("reviews.book.ownerInfo.name==Barry"); assertEquals(1,books.size()); }

EqualityVerifier 
@Test public void testNumberOfReviewAuthors() throws Exception { List books=queryBooks("count(reviews.authors)=gt=0"); assertEquals(3,books.size()); }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testAndQueryCollection() throws Exception { List books=queryBooks("id==10;authors==John;reviews.review==good;reviews.authors==Ted"); assertEquals(1,books.size()); assertTrue(10 == books.get(0).getId() && "num10".equals(books.get(0).getBookTitle())); }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testNotEqualsQuery() throws Exception { List books=queryBooks("id!=10"); assertEquals(2,books.size()); assertTrue(9 == books.get(0).getId() && 11 == books.get(1).getId() || 11 == books.get(0).getId() && 9 == books.get(1).getId()); }

EqualityVerifier 
@Test public void testQueryElementCollection() throws Exception { List books=queryBooks("authors==John"); assertEquals(2,books.size()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testEqualsCriteriaQueryArray() throws Exception { List books=criteriaQueryBooksArray("id==10"); assertEquals(1,books.size()); Object[] info=books.get(0); assertEquals(10,((Integer)info[0]).intValue()); assertEquals("num10",(String)info[1]); }

EqualityVerifier 
@Test public void testAndQueryNoMatch() throws Exception { List books=queryBooks("id==10;bookTitle==num9"); assertEquals(0,books.size()); }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testLessEqualQuery() throws Exception { List books=queryBooks("id=le=10"); assertEquals(2,books.size()); assertTrue(9 == books.get(0).getId() && 10 == books.get(1).getId() || 9 == books.get(0).getId() && 10 == books.get(1).getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testEqualsCriteriaQueryConstruct() throws Exception { List books=criteriaQueryBooksConstruct("id==10"); assertEquals(1,books.size()); BookInfo info=books.get(0); assertEquals(10,info.getId()); assertEquals("num10",info.getTitle()); }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testEqualsWildcard() throws Exception { List books=queryBooks("bookTitle==num1*"); assertEquals(2,books.size()); assertTrue(10 == books.get(0).getId() && 11 == books.get(1).getId() || 11 == books.get(0).getId() && 10 == books.get(1).getId()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testEqualsOwnerNameQuery() throws Exception { List books=queryBooks("ownerInfo.name.name==Fred"); assertEquals(1,books.size()); Book book=books.get(0); assertEquals("Fred",book.getOwnerInfo().getName().getName()); }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testOrQuery() throws Exception { List books=queryBooks("id=lt=10,id=gt=10"); assertEquals(2,books.size()); assertTrue(9 == books.get(0).getId() && 11 == books.get(1).getId() || 11 == books.get(0).getId() && 9 == books.get(1).getId()); }

EqualityVerifier 
@Test public void testQueryCollection() throws Exception { List books=queryBooks("reviews.authors==Ted"); assertEquals(3,books.size()); }

EqualityVerifier 
@Test public void testOrderByDesc() throws Exception { List books=criteriaQueryBooksOrderBy("reviews=gt=0",false); assertEquals(3,books.size()); assertEquals(11,books.get(0).getId()); assertEquals(10,books.get(1).getId()); assertEquals(9,books.get(2).getId()); }

Class: org.apache.cxf.jaxrs.ext.search.jpa.JPATypedQueryVisitorODataTest

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testLessEqualQuery() throws Exception { List books=queryBooks("id le 10"); assertEquals(2,books.size()); assertTrue(9 == books.get(0).getId() && 10 == books.get(1).getId() || 9 == books.get(0).getId() && 10 == books.get(1).getId()); }

EqualityVerifier 
@Test public void testQueryCollection2() throws Exception { List books=queryBooks("reviews.book.id eq 10"); assertEquals(1,books.size()); }

EqualityVerifier 
@Test public void testQueryCollectionSize2() throws Exception { List books=queryBooks("reviews.authors gt 0"); assertEquals(3,books.size()); }

EqualityVerifier 
@Test public void testEqualsCriteriaQueryCount() throws Exception { assertEquals(1L,criteriaQueryBooksCount("id eq 10")); }

EqualityVerifier 
@Test public void testQueryCollection3() throws Exception { List books=queryBooks("reviews.book.ownerInfo.name eq 'Barry'"); assertEquals(1,books.size()); }

EqualityVerifier 
@Test public void testOrQueryNoMatch() throws Exception { List books=queryBooks("id eq 7 or id eq 5"); assertEquals(0,books.size()); }

EqualityVerifier 
@Test public void testOrderByAsc() throws Exception { List books=criteriaQueryBooksOrderBy("reviews gt 0",true); assertEquals(3,books.size()); assertEquals(9,books.get(0).getId()); assertEquals(10,books.get(1).getId()); assertEquals(11,books.get(2).getId()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testEqualsOwnerNameQuery() throws Exception { List books=queryBooks("ownerInfo.name.name eq 'Fred'"); assertEquals(1,books.size()); Book book=books.get(0); assertEquals("Fred",book.getOwnerInfo().getName().getName()); }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testGreaterEqualQuery() throws Exception { List books=queryBooks("id ge 10"); assertEquals(2,books.size()); assertTrue(10 == books.get(0).getId() && 11 == books.get(1).getId() || 11 == books.get(0).getId() && 10 == books.get(1).getId()); }

EqualityVerifier 
@Test public void testNumberOfReviews() throws Exception { List books=queryBooks("reviews gt 0"); assertEquals(3,books.size()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testEqualsCriteriaQueryConstruct() throws Exception { List books=criteriaQueryBooksConstruct("id eq 10"); assertEquals(1,books.size()); BookInfo info=books.get(0); assertEquals(10,info.getId()); assertEquals("num10",info.getTitle()); }

EqualityVerifier 
@Test public void testAndQueryNoMatch() throws Exception { List books=queryBooks("id eq 10 and bookTitle eq 'num9'"); assertEquals(0,books.size()); }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testOrQuery() throws Exception { List books=queryBooks("id lt 10 or id gt 10"); assertEquals(2,books.size()); assertTrue(9 == books.get(0).getId() && 11 == books.get(1).getId() || 11 == books.get(0).getId() && 9 == books.get(1).getId()); }

EqualityVerifier 
@Test public void testNumberOfReviews2() throws Exception { List books=queryBooks("reviews gt 3"); assertEquals(0,books.size()); }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testEqualsWildcard() throws Exception { List books=queryBooks("bookTitle eq 'num1*'"); assertEquals(2,books.size()); assertTrue(10 == books.get(0).getId() && 11 == books.get(1).getId() || 11 == books.get(0).getId() && 10 == books.get(1).getId()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testEqualsAddressQuery() throws Exception { List books=queryBooks("address eq 'Street1'",Collections.singletonMap("address","address.street")); assertEquals(1,books.size()); Book book=books.get(0); assertTrue(9 == book.getId()); assertEquals("Street1",book.getAddress().getStreet()); }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testEqualsQuery() throws Exception { List books=queryBooks("id eq 10"); assertEquals(1,books.size()); assertTrue(10 == books.get(0).getId()); }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testAndQuery() throws Exception { List books=queryBooks("id eq 10 and bookTitle eq 'num10'"); assertEquals(1,books.size()); assertTrue(10 == books.get(0).getId() && "num10".equals(books.get(0).getBookTitle())); }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testGreaterQuery() throws Exception { List books=queryBooks("id gt 10"); assertEquals(1,books.size()); assertTrue(11 == books.get(0).getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testEqualsCriteriaQueryTuple() throws Exception { List books=criteriaQueryBooksTuple("id eq 10"); assertEquals(1,books.size()); Tuple tuple=books.get(0); int tupleId=tuple.get("id",Integer.class); assertEquals(10,tupleId); }

APIUtilityVerifier EqualityVerifier 
@Test public void testEqualsCriteriaQueryArray() throws Exception { List books=criteriaQueryBooksArray("id eq 10"); assertEquals(1,books.size()); Object[] info=books.get(0); assertEquals(10,((Integer)info[0]).intValue()); assertEquals("num10",(String)info[1]); }

EqualityVerifier 
@Test public void testQueryElementCollection() throws Exception { List books=queryBooks("authors eq 'John'"); assertEquals(2,books.size()); }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testAndQueryCollection() throws Exception { List books=queryBooks("id eq 10 and authors eq 'John' and reviews.review eq 'good' and reviews.authors eq 'Ted'"); assertEquals(1,books.size()); assertTrue(10 == books.get(0).getId() && "num10".equals(books.get(0).getBookTitle())); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testEqualsOwnerBirthDate() throws Exception { List books=queryBooks("ownerbdate eq '2000-01-01'",null,Collections.singletonMap("ownerbdate","ownerInfo.dateOfBirth")); assertEquals(1,books.size()); Book book=books.get(0); assertEquals("Fred",book.getOwnerInfo().getName().getName()); Date d=parseDate("2000-01-01"); assertEquals("Fred",book.getOwnerInfo().getName().getName()); assertEquals(d,book.getOwnerInfo().getDateOfBirth()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testEqualsAddressQuery4() throws Exception { Map beanPropertiesMap=new HashMap(); beanPropertiesMap.put("street","address.street"); List books=queryBooks("street eq 'Str*t*'",null,beanPropertiesMap); assertEquals(3,books.size()); }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testNotEqualsQuery() throws Exception { List books=queryBooks("id ne 10"); assertEquals(2,books.size()); assertTrue(9 == books.get(0).getId() && 11 == books.get(1).getId() || 11 == books.get(0).getId() && 9 == books.get(1).getId()); }

EqualityVerifier 
@Test public void testOrderByDesc() throws Exception { List books=criteriaQueryBooksOrderBy("reviews gt 0",false); assertEquals(3,books.size()); assertEquals(11,books.get(0).getId()); assertEquals(10,books.get(1).getId()); assertEquals(9,books.get(2).getId()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testEqualsAddressQuery3() throws Exception { Map beanPropertiesMap=new HashMap(); beanPropertiesMap.put("street","address.street"); beanPropertiesMap.put("housenum","address.houseNumber"); List books=queryBooks("street eq 'Street2' and housenum lt 5",null,beanPropertiesMap); assertEquals(1,books.size()); Book book=books.get(0); assertTrue(10 == book.getId()); assertEquals("Street2",book.getAddress().getStreet()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testEqualsOwnerNameQuery2() throws Exception { List books=queryBooks("ownerInfo.name eq 'Fred'"); assertEquals(1,books.size()); Book book=books.get(0); assertEquals("Fred",book.getOwnerInfo().getName().getName()); }

EqualityVerifier 
@Test public void testQueryCollection() throws Exception { List books=queryBooks("reviews.authors eq 'Ted'"); assertEquals(3,books.size()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testEqualsAddressQuery2() throws Exception { List books=queryBooks("street eq 'Street1'",null,Collections.singletonMap("street","address.street")); assertEquals(1,books.size()); Book book=books.get(0); assertTrue(9 == book.getId()); assertEquals("Street1",book.getAddress().getStreet()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testEqualsAddressQuery5() throws Exception { Map beanPropertiesMap=new HashMap(); beanPropertiesMap.put("street","address.street"); List books=queryBooks("street eq 'Street&''3'",null,beanPropertiesMap); assertEquals(1,books.size()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testFindBookInTownLibrary() throws Exception { List books=queryBooks("libAddress eq 'town' and bookTitle eq 'num10'",null,Collections.singletonMap("libAddress","library.address")); assertEquals(1,books.size()); Book book=books.get(0); assertEquals("Barry",book.getOwnerInfo().getName().getName()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testEqualsOwnerNameQuery3() throws Exception { List books=queryBooks("ownerName eq 'Fred'",null,Collections.singletonMap("ownerName","ownerInfo.name.name")); assertEquals(1,books.size()); Book book=books.get(0); assertEquals("Fred",book.getOwnerInfo().getName().getName()); }

Class: org.apache.cxf.jaxrs.ext.search.ldap.LdapQueryVisitorTest

InternalCallVerifier EqualityVerifier 
@Test public void testComplexQuery() throws SearchParseException { SearchCondition filter=parser.parse("(name==test,level==18);(name==test1,level!=19)"); LdapQueryVisitor visitor=new LdapQueryVisitor(); filter.accept(visitor.visitor()); String ldap=visitor.getQuery(); assertEquals("(&(|(name=test)(level=18))(|(name=test1)(!level=19)))",ldap); }

InternalCallVerifier EqualityVerifier 
@Test public void testSimple() throws SearchParseException { SearchCondition filter=parser.parse("name!=ami"); LdapQueryVisitor visitor=new LdapQueryVisitor(); filter.accept(visitor.visitor()); String ldap=visitor.getQuery(); assertEquals("(!name=ami)",ldap); }

InternalCallVerifier EqualityVerifier 
@Test public void testAndQuery() throws SearchParseException { SearchCondition filter=parser.parse("name==ami*;level=gt=10"); LdapQueryVisitor visitor=new LdapQueryVisitor(); filter.accept(visitor.visitor()); String ldap=visitor.getQuery(); assertEquals("(&(name=ami*)(level>=10))",ldap); }

InternalCallVerifier EqualityVerifier 
@Test public void testOrQuery() throws SearchParseException { SearchCondition filter=parser.parse("name==ami*,level=gt=10"); LdapQueryVisitor visitor=new LdapQueryVisitor(); filter.accept(visitor.visitor()); String ldap=visitor.getQuery(); assertEquals("(|(name=ami*)(level>=10))",ldap); }

InternalCallVerifier EqualityVerifier 
@Test public void testAndOrQuery() throws SearchParseException { SearchCondition filter=parser.parse("name==foo;(name!=bar,level=le=10)"); LdapQueryVisitor visitor=new LdapQueryVisitor(); filter.accept(visitor.visitor()); String ldap=visitor.getQuery(); assertEquals("(&(name=foo)(|(!name=bar)(level<=10)))",ldap); }

Class: org.apache.cxf.jaxrs.ext.search.tika.TikaLuceneContentExtractorTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testExtractedTextContentMatchesTypesAndLongSearchCriteria() throws Exception { final LuceneDocumentMetadata documentMetadata=new LuceneDocumentMetadata("contents").withField("xmpTPg:NPages",Long.class); final Document document=extractor.extract(getClass().getResourceAsStream("/files/testPDF.pdf"),documentMetadata); assertNotNull("Document should not be null",document); writer.addDocument(document); writer.commit(); assertEquals(1,getHits("xmpTPg:NPages=gt=0",documentMetadata.getFieldTypes()).length); assertEquals(1,getHits("xmpTPg:NPages==1",documentMetadata.getFieldTypes()).length); assertEquals(1,getHits("xmpTPg:NPages=ge=1",documentMetadata.getFieldTypes()).length); assertEquals(0,getHits("xmpTPg:NPages=gt=1",documentMetadata.getFieldTypes()).length); assertEquals(0,getHits("xmpTPg:NPages=lt=1",documentMetadata.getFieldTypes()).length); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testExtractedTextContentMatchesTypesAndIntegerSearchCriteria() throws Exception { final LuceneDocumentMetadata documentMetadata=new LuceneDocumentMetadata("contents").withField("xmpTPg:NPages",Integer.class); final Document document=extractor.extract(getClass().getResourceAsStream("/files/testPDF.pdf"),documentMetadata); assertNotNull("Document should not be null",document); writer.addDocument(document); writer.commit(); assertEquals(1,getHits("xmpTPg:NPages=gt=0",documentMetadata.getFieldTypes()).length); assertEquals(1,getHits("xmpTPg:NPages==1",documentMetadata.getFieldTypes()).length); assertEquals(1,getHits("xmpTPg:NPages=ge=1",documentMetadata.getFieldTypes()).length); assertEquals(0,getHits("xmpTPg:NPages=gt=1",documentMetadata.getFieldTypes()).length); assertEquals(0,getHits("xmpTPg:NPages=lt=1",documentMetadata.getFieldTypes()).length); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testExtractedTextContentMatchesTypesAndDateSearchCriteria() throws Exception { final LuceneDocumentMetadata documentMetadata=new LuceneDocumentMetadata("contents").withField("modified",Date.class); final Document document=extractor.extract(getClass().getResourceAsStream("/files/testPDF.pdf"),documentMetadata); assertNotNull("Document should not be null",document); writer.addDocument(document); writer.commit(); assertEquals(1,getHits("modified=gt=2007-09-14T09:02:31Z",documentMetadata.getFieldTypes()).length); assertEquals(1,getHits("modified=le=2007-09-15T09:02:31-0500",documentMetadata.getFieldTypes()).length); assertEquals(1,getHits("modified=ge=2007-09-15",documentMetadata.getFieldTypes()).length); assertEquals(1,getHits("modified==2007-09-15",documentMetadata.getFieldTypes()).length); assertEquals(0,getHits("modified==2007-09-16",documentMetadata.getFieldTypes()).length); assertEquals(0,getHits("modified=gt=2007-09-16",documentMetadata.getFieldTypes()).length); assertEquals(0,getHits("modified=lt=2007-09-15",documentMetadata.getFieldTypes()).length); assertEquals(0,getHits("modified=gt=2007-09-16T09:02:31",documentMetadata.getFieldTypes()).length); assertEquals(0,getHits("modified=lt=2007-09-01T09:02:31",documentMetadata.getFieldTypes()).length); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testContentSourceMatchesSearchCriteria() throws Exception { final LuceneDocumentMetadata documentMetadata=new LuceneDocumentMetadata().withSource("testPDF.pdf"); final Document document=extractor.extract(getClass().getResourceAsStream("/files/testPDF.pdf"),documentMetadata); assertNotNull("Document should not be null",document); writer.addDocument(document); writer.commit(); assertEquals(1,getHits("source==testPDF.pdf").length); assertEquals(0,getHits("source==testPDF").length); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testExtractedTextContentMatchesSearchCriteria() throws Exception { final Document document=extractor.extract(getClass().getResourceAsStream("/files/testPDF.pdf")); assertNotNull("Document should not be null",document); writer.addDocument(document); writer.commit(); assertEquals(1,getHits("ct==tika").length); assertEquals(1,getHits("ct==incubation").length); assertEquals(0,getHits("ct==toolsuite").length); assertEquals(1,getHits("Author==Bertrand*").length); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testExtractedTextContentMatchesTypesAndDoubleSearchCriteria() throws Exception { final LuceneDocumentMetadata documentMetadata=new LuceneDocumentMetadata("contents").withField("xmpTPg:NPages",Double.class); final Document document=extractor.extract(getClass().getResourceAsStream("/files/testPDF.pdf"),documentMetadata); assertNotNull("Document should not be null",document); writer.addDocument(document); writer.commit(); assertEquals(1,getHits("xmpTPg:NPages=gt=0.0",documentMetadata.getFieldTypes()).length); assertEquals(1,getHits("xmpTPg:NPages==1.0",documentMetadata.getFieldTypes()).length); assertEquals(1,getHits("xmpTPg:NPages=ge=1.0",documentMetadata.getFieldTypes()).length); assertEquals(0,getHits("xmpTPg:NPages=gt=1.0",documentMetadata.getFieldTypes()).length); assertEquals(0,getHits("xmpTPg:NPages=lt=1.0",documentMetadata.getFieldTypes()).length); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testExtractedTextContentMatchesTypesAndFloatSearchCriteria() throws Exception { final LuceneDocumentMetadata documentMetadata=new LuceneDocumentMetadata("contents").withField("xmpTPg:NPages",Float.class); final Document document=extractor.extract(getClass().getResourceAsStream("/files/testPDF.pdf"),documentMetadata); assertNotNull("Document should not be null",document); writer.addDocument(document); writer.commit(); assertEquals(1,getHits("xmpTPg:NPages=gt=0.0",documentMetadata.getFieldTypes()).length); assertEquals(1,getHits("xmpTPg:NPages==1.0",documentMetadata.getFieldTypes()).length); assertEquals(1,getHits("xmpTPg:NPages=ge=1.0",documentMetadata.getFieldTypes()).length); assertEquals(0,getHits("xmpTPg:NPages=gt=1.0",documentMetadata.getFieldTypes()).length); assertEquals(0,getHits("xmpTPg:NPages=lt=1.0",documentMetadata.getFieldTypes()).length); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testExtractedTextContentMatchesTypesAndByteSearchCriteria() throws Exception { final LuceneDocumentMetadata documentMetadata=new LuceneDocumentMetadata("contents").withField("xmpTPg:NPages",Byte.class); final Document document=extractor.extract(getClass().getResourceAsStream("/files/testPDF.pdf"),documentMetadata); assertNotNull("Document should not be null",document); writer.addDocument(document); writer.commit(); assertEquals(1,getHits("xmpTPg:NPages=gt=0",documentMetadata.getFieldTypes()).length); assertEquals(1,getHits("xmpTPg:NPages==1",documentMetadata.getFieldTypes()).length); assertEquals(1,getHits("xmpTPg:NPages=ge=1",documentMetadata.getFieldTypes()).length); assertEquals(0,getHits("xmpTPg:NPages=gt=1",documentMetadata.getFieldTypes()).length); assertEquals(0,getHits("xmpTPg:NPages=lt=1",documentMetadata.getFieldTypes()).length); }

Class: org.apache.cxf.jaxrs.ext.xml.XMLSourceTest

InternalCallVerifier EqualityVerifier 
@Test public void testGetStringValue(){ InputStream is=new ByteArrayInputStream("".getBytes()); XMLSource xp=new XMLSource(is); String value=xp.getValue("/foo/bar/@id"); assertEquals("2",value); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetRelativeLink(){ InputStream is=new ByteArrayInputStream("".getBytes()); XMLSource xp=new XMLSource(is); URI value=xp.getLink("/foo/bar/@href"); assertEquals("/2",value.toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testAttributeValue(){ InputStream is=new ByteArrayInputStream("barValue".getBytes()); XMLSource xp=new XMLSource(is); xp.setBuffering(); assertEquals("baz",xp.getValue("/foo/bar/@attr")); }

InternalCallVerifier EqualityVerifier 
@Test public void testBaseURI(){ InputStream is=new ByteArrayInputStream("".getBytes()); XMLSource xp=new XMLSource(is); URI value=xp.getBaseURI(); assertEquals("http://bar",value.toString()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetNodeAsJaxbElement(){ InputStream is=new ByteArrayInputStream("".getBytes()); XMLSource xp=new XMLSource(is); xp.setBuffering(); Bar3 bar=xp.getNode("/foo/bar",Bar3.class); assertNotNull(bar); assertEquals("foo",bar.getName()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testIntegerValues(){ InputStream is=new ByteArrayInputStream("".getBytes()); XMLSource xp=new XMLSource(is); xp.setBuffering(); Integer[] values=xp.getNodes("/foo/bar/@attr",Integer.class); assertEquals(2,values.length); assertTrue(values[0] == 1 && values[1] == 2 || values[0] == 2 && values[1] == 1); }

APIUtilityVerifier InternalCallVerifier IdentityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetNodesNamespace(){ String data=""; InputStream is=new ByteArrayInputStream(data.getBytes()); XMLSource xp=new XMLSource(is); xp.setBuffering(); Map map=new LinkedHashMap(); map.put("x","http://baz"); Bar2[] bars=xp.getNodes("/x:foo/x:bar",map,Bar2.class); assertNotNull(bars); assertNotNull(bars); assertEquals(2,bars.length); assertNotSame(bars[0],bars[1]); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testNodeTextValues(){ InputStream is=new ByteArrayInputStream("bar1bar2".getBytes()); XMLSource xp=new XMLSource(is); xp.setBuffering(); List values=Arrays.asList(xp.getValues("/foo/bar/text()")); assertEquals(2,values.size()); assertTrue(values.contains("bar1")); assertTrue(values.contains("bar2")); }

InternalCallVerifier EqualityVerifier 
@Test public void testNodeTextValue(){ InputStream is=new ByteArrayInputStream("barValue".getBytes()); XMLSource xp=new XMLSource(is); xp.setBuffering(); assertEquals("barValue",xp.getValue("/foo/bar")); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testAttributeValues(){ InputStream is=new ByteArrayInputStream("bar1bar2".getBytes()); XMLSource xp=new XMLSource(is); xp.setBuffering(); List values=Arrays.asList(xp.getValues("/foo/bar/@attr")); assertEquals(2,values.size()); assertTrue(values.contains("baz")); assertTrue(values.contains("baz2")); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAttributeValueAsNode(){ InputStream is=new ByteArrayInputStream("barValue".getBytes()); XMLSource xp=new XMLSource(is); xp.setBuffering(); Node node=xp.getNode("/foo/bar/@attr",Node.class); assertNotNull(node); assertEquals("baz",node.getTextContent()); }

InternalCallVerifier IdentityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetNodesNoNamespace(){ InputStream is=new ByteArrayInputStream("".getBytes()); XMLSource xp=new XMLSource(is); xp.setBuffering(); Bar[] bars=xp.getNodes("/foo/bar",Bar.class); assertNotNull(bars); assertEquals(2,bars.length); assertNotSame(bars[0],bars[1]); }

Class: org.apache.cxf.jaxrs.impl.CacheControlHeaderProviderTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testReadMultiplePrivateAndNoCacheFields(){ String s="private=\"foo1,foo2\",no-store,no-transform," + "must-revalidate,proxy-revalidate,max-age=2,s-maxage=3,no-cache=\"bar1,bar2\"," + "ext=1"; CacheControl cc=CacheControl.valueOf(s); assertTrue(cc.isPrivate()); List privateFields=cc.getPrivateFields(); assertEquals(2,privateFields.size()); assertEquals("foo1",privateFields.get(0)); assertEquals("foo2",privateFields.get(1)); assertTrue(cc.isNoCache()); List noCacheFields=cc.getNoCacheFields(); assertEquals(2,noCacheFields.size()); assertEquals("bar1",noCacheFields.get(0)); assertEquals("bar2",noCacheFields.get(1)); assertTrue(cc.isNoStore()); assertTrue(cc.isNoTransform()); assertTrue(cc.isMustRevalidate()); assertTrue(cc.isProxyRevalidate()); assertEquals(2,cc.getMaxAge()); assertEquals(3,cc.getSMaxAge()); Map exts=cc.getCacheExtension(); assertEquals(1,exts.size()); assertEquals("1",exts.get("ext")); }

APIUtilityVerifier EqualityVerifier 
@Test public void testToString(){ String s="private=\"foo\",no-cache=\"bar\",no-store,no-transform," + "must-revalidate,proxy-revalidate,max-age=2,s-maxage=3"; String parsed=CacheControl.valueOf(s).toString(); assertEquals(s,parsed); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testFromComplexString(){ CacheControl c=CacheControl.valueOf("private=\"foo\",no-cache=\"bar\",no-store,no-transform," + "must-revalidate,proxy-revalidate,max-age=2,s-maxage=3"); assertTrue(c.isPrivate() && c.isNoStore() && c.isMustRevalidate()&& c.isProxyRevalidate()&& c.isNoCache()); assertTrue(c.isNoTransform() && c.getNoCacheFields().size() == 1 && c.getPrivateFields().size() == 1); assertEquals("foo",c.getPrivateFields().get(0)); assertEquals("bar",c.getNoCacheFields().get(0)); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testFromComplexStringWithSemicolon(){ CacheControlHeaderProvider cp=new CacheControlHeaderProvider(){ protected Message getCurrentMessage(){ Message m=new MessageImpl(); m.put(CacheControlHeaderProvider.CACHE_CONTROL_SEPARATOR_PROPERTY,";"); return m; } } ; CacheControl c=cp.fromString("private=\"foo\";no-cache=\"bar\";no-store;no-transform;" + "must-revalidate;proxy-revalidate;max-age=2;s-maxage=3"); assertTrue(c.isPrivate() && c.isNoStore() && c.isMustRevalidate()&& c.isProxyRevalidate()&& c.isNoCache()); assertTrue(c.isNoTransform() && c.getNoCacheFields().size() == 1 && c.getPrivateFields().size() == 1); assertEquals("foo",c.getPrivateFields().get(0)); assertEquals("bar",c.getNoCacheFields().get(0)); }

InternalCallVerifier EqualityVerifier 
@Test public void testNoCacheEnabled(){ CacheControl cc=new CacheControl(); cc.setNoCache(true); assertEquals("no-cache,no-transform",cc.toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testNoCacheDisabled(){ CacheControl cc=new CacheControl(); cc.setNoCache(false); assertEquals("no-transform",cc.toString()); }

Class: org.apache.cxf.jaxrs.impl.CookieHeaderProviderTest

EqualityVerifier 
@Test public void testToStringWithQuotes(){ Cookie c=new Cookie("foo","bar z","path","domain",2); assertEquals("$Version=2;foo=\"bar z\";$Path=path;$Domain=domain",c.toString()); }

EqualityVerifier 
@Test public void testToString(){ Cookie c=new Cookie("foo","bar","path","domain",2); assertEquals("$Version=2;foo=bar;$Path=path;$Domain=domain",c.toString()); }

Class: org.apache.cxf.jaxrs.impl.DateHeaderProviderTest

InternalCallVerifier EqualityVerifier 
@Test public void testToFromSimpleString(){ Date retry=new Date(); ServiceUnavailableException ex=new ServiceUnavailableException(retry); Date retry2=ex.getRetryTime(new Date()); assertEquals(HttpUtils.toHttpDate(retry),HttpUtils.toHttpDate(retry2)); }

Class: org.apache.cxf.jaxrs.impl.EntityTagHeaderProviderTest

EqualityVerifier 
@Test public void testToString(){ EntityTag tag=new EntityTag(""); assertEquals("\"\"",tag.toString()); tag=new EntityTag("",true); assertEquals("W/\"\"",tag.toString()); tag=new EntityTag("bar"); assertEquals("\"bar\"",tag.toString()); }

Class: org.apache.cxf.jaxrs.impl.EvaluatePreconditionsTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testIfNoneMatchIfModified200(){ final Request request=getRequest(HttpHeaders.IF_MODIFIED_SINCE,DATE_FMT_822.format(DATE_OLD),HttpHeaders.IF_NONE_MATCH,ETAG_NEW.toString()); final Response response=service.perform(request); Assert.assertEquals(HttpServletResponse.SC_OK,response.getStatus()); }

InternalCallVerifier EqualityVerifier 
@Test public void testIfNoneMatch200(){ final Request request=getRequest(HttpHeaders.IF_NONE_MATCH,ETAG_NEW.toString()); final Response response=service.perform(request); Assert.assertEquals(HttpServletResponse.SC_OK,response.getStatus()); }

InternalCallVerifier EqualityVerifier 
@Test public void testIfNoneMatch304(){ final Request request=getRequest(HttpHeaders.IF_NONE_MATCH,ETAG_OLD.toString()); final Response response=service.perform(request); Assert.assertEquals(HttpServletResponse.SC_NOT_MODIFIED,response.getStatus()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testIfModified304(){ final Request request=getRequest(HttpHeaders.IF_MODIFIED_SINCE,DATE_FMT_822.format(DATE_NEW)); final Response response=service.perform(request); Assert.assertEquals(HttpServletResponse.SC_NOT_MODIFIED,response.getStatus()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testIfNoneMatchIfModified304(){ final Request request=getRequest(HttpHeaders.IF_MODIFIED_SINCE,DATE_FMT_822.format(DATE_OLD),HttpHeaders.IF_NONE_MATCH,ETAG_OLD.toString()); final Response response=service.perform(request); Assert.assertEquals(HttpServletResponse.SC_NOT_MODIFIED,response.getStatus()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testIfModified200(){ service.setLastModified(DATE_NEW); final Request request=getRequest(HttpHeaders.IF_MODIFIED_SINCE,DATE_FMT_822.format(DATE_OLD)); final Response response=service.perform(request); Assert.assertEquals(HttpServletResponse.SC_OK,response.getStatus()); }

InternalCallVerifier EqualityVerifier 
@Test public void testUnconditional200(){ final Request request=getRequest(); final Response response=service.perform(request); Assert.assertEquals(HttpServletResponse.SC_OK,response.getStatus()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testIfNoneMatchIfModified200Two(){ service.setLastModified(DATE_NEW); final Request request=getRequest(HttpHeaders.IF_MODIFIED_SINCE,DATE_FMT_822.format(DATE_OLD),HttpHeaders.IF_NONE_MATCH,ETAG_NEW.toString()); final Response response=service.perform(request); Assert.assertEquals(HttpServletResponse.SC_OK,response.getStatus()); }

Class: org.apache.cxf.jaxrs.impl.HttpHeadersImplTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetHeaderNameValue() throws Exception { Message m=control.createMock(Message.class); m.get(Message.PROTOCOL_HEADERS); MetadataMap headers=createHeader("COMPLEX_HEADER","b=c; param=c, a=b;param=b"); EasyMock.expectLastCall().andReturn(headers); m.getContextualProperty("org.apache.cxf.http.header.split"); EasyMock.expectLastCall().andReturn("true"); control.replay(); HttpHeaders h=new HttpHeadersImpl(m); List values=h.getRequestHeader("COMPLEX_HEADER"); assertNotNull(values); assertEquals(2,values.size()); assertEquals("b=c; param=c",values.get(0)); assertEquals("a=b;param=b",values.get(1)); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetNoMediaTypes() throws Exception { Message m=control.createMock(Message.class); m.get(Message.PROTOCOL_HEADERS); EasyMock.expectLastCall().andReturn(Collections.emptyMap()); control.replay(); HttpHeaders h=new HttpHeadersImpl(m); List acceptValues=h.getAcceptableMediaTypes(); assertEquals(1,acceptValues.size()); assertEquals("*/*",acceptValues.get(0).toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetNoLanguages() throws Exception { Message m=control.createMock(Message.class); m.get(Message.PROTOCOL_HEADERS); EasyMock.expectLastCall().andReturn(Collections.emptyMap()); control.replay(); HttpHeaders h=new HttpHeadersImpl(m); List locales=h.getAcceptableLanguages(); assertEquals(1,locales.size()); assertEquals("*",locales.get(0).toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testSingleAcceptableLanguages() throws Exception { Message m=control.createMock(Message.class); m.get(Message.PROTOCOL_HEADERS); MetadataMap headers=createHeaders(); headers.putSingle(HttpHeaders.ACCEPT_LANGUAGE,"en"); EasyMock.expectLastCall().andReturn(headers); control.replay(); HttpHeaders h=new HttpHeadersImpl(m); List languages=h.getAcceptableLanguages(); assertEquals(1,languages.size()); assertEquals(new Locale("en"),languages.get(0)); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetHeaderWithQuotes1() throws Exception { Message m=control.createMock(Message.class); m.getContextualProperty("org.apache.cxf.http.header.split"); EasyMock.expectLastCall().andReturn("true"); m.get(Message.PROTOCOL_HEADERS); MetadataMap headers=createHeader("COMPLEX_HEADER","a1=\"a\", a2=\"a\";param, b, b;param, c1=\"c, d, e\", " + "c2=\"c, d, e\";param, a=b, a=b;p=p1, a2=\"a\";param=p," + "a3=\"a\";param=\"p,b\""); EasyMock.expectLastCall().andReturn(headers); control.replay(); HttpHeaders h=new HttpHeadersImpl(m); List values=h.getRequestHeader("COMPLEX_HEADER"); assertNotNull(values); assertEquals(10,values.size()); assertEquals("a1=\"a\"",values.get(0)); assertEquals("a2=\"a\";param",values.get(1)); assertEquals("b",values.get(2)); assertEquals("b;param",values.get(3)); assertEquals("c1=\"c, d, e\"",values.get(4)); assertEquals("c2=\"c, d, e\";param",values.get(5)); assertEquals("a=b",values.get(6)); assertEquals("a=b;p=p1",values.get(7)); assertEquals("a2=\"a\";param=p",values.get(8)); assertEquals("a3=\"a\";param=\"p,b\"",values.get(9)); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetHeaderString2() throws Exception { Message m=new MessageImpl(); m.put(Message.PROTOCOL_HEADERS,createHeaders()); HttpHeaders h=new HttpHeadersImpl(m); String date=h.getHeaderString("a"); assertEquals("1,2",date); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetHeader2() throws Exception { Message m=new MessageImpl(); m.put(Message.PROTOCOL_HEADERS,createHeaders()); HttpHeaders h=new HttpHeadersImpl(m); List values=h.getRequestHeader("a"); assertEquals(2,values.size()); assertEquals("1",values.get(0)); assertEquals("2",values.get(1)); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetCookiesWithAttributes() throws Exception { Message m=new MessageImpl(); m.setExchange(new ExchangeImpl()); MetadataMap headers=createHeaders(); headers.putSingle(HttpHeaders.COOKIE,"$Version=1;a=b, $Version=1;c=d"); m.put(Message.PROTOCOL_HEADERS,headers); HttpHeaders h=new HttpHeadersImpl(m); Map cookies=h.getCookies(); assertEquals(2,cookies.size()); Cookie cookieA=cookies.get("a"); assertEquals("b",cookieA.getValue()); assertEquals(1,cookieA.getVersion()); Cookie cookieC=cookies.get("c"); assertEquals("d",cookieC.getValue()); assertEquals(1,cookieA.getVersion()); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetContentTypeLowCase() throws Exception { Message m=new MessageImpl(); Map> headers=new TreeMap>(String.CASE_INSENSITIVE_ORDER); headers.put("content-type",Collections.singletonList("text/plain")); m.put(Message.PROTOCOL_HEADERS,headers); HttpHeaders h=new HttpHeadersImpl(m); assertEquals("text/plain",h.getRequestHeaders().getFirst("Content-Type")); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetCookies() throws Exception { Message m=new MessageImpl(); m.setExchange(new ExchangeImpl()); MetadataMap headers=createHeaders(); headers.putSingle(HttpHeaders.COOKIE,"a=$b;c=d"); m.put(Message.PROTOCOL_HEADERS,headers); HttpHeaders h=new HttpHeadersImpl(m); Map cookies=h.getCookies(); assertEquals(2,cookies.size()); assertEquals("$b",cookies.get("a").getValue()); assertEquals("d",cookies.get("c").getValue()); }

InternalCallVerifier EqualityVerifier 
@Test public void testMediaType() throws Exception { Message m=control.createMock(Message.class); m.get(Message.PROTOCOL_HEADERS); EasyMock.expectLastCall().andReturn(createHeaders()); control.replay(); HttpHeaders h=new HttpHeadersImpl(m); assertEquals(MediaType.valueOf("*/*"),h.getMediaType()); }

InternalCallVerifier EqualityVerifier 
@Test public void testMultipleAcceptableLanguages() throws Exception { Message m=control.createMock(Message.class); m.get(Message.PROTOCOL_HEADERS); MetadataMap headers=createHeader(HttpHeaders.ACCEPT_LANGUAGE,"en;q=0.7, en-gb;q=0.8, da, zh-Hans-SG;q=0.9"); EasyMock.expectLastCall().andReturn(headers); control.replay(); HttpHeaders h=new HttpHeadersImpl(m); List languages=h.getAcceptableLanguages(); assertEquals(4,languages.size()); assertEquals(new Locale("da"),languages.get(0)); assertEquals(new Locale("zh","Hans-SG"),languages.get(1)); assertEquals(new Locale("en","GB"),languages.get(2)); assertEquals(new Locale("en"),languages.get(3)); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetHeaderWithQuotes2() throws Exception { Message m=control.createMock(Message.class); m.getContextualProperty("org.apache.cxf.http.header.split"); EasyMock.expectLastCall().andReturn("true"); m.get(Message.PROTOCOL_HEADERS); MetadataMap headers=createHeader("X-WSSE","UsernameToken Username=\"Foo\", Nonce=\"bar\""); EasyMock.expectLastCall().andReturn(headers); control.replay(); HttpHeaders h=new HttpHeadersImpl(m); List values=h.getRequestHeader("X-WSSE"); assertNotNull(values); assertEquals(3,values.size()); assertEquals("UsernameToken",values.get(0)); assertEquals("Username=\"Foo\"",values.get(1)); assertEquals("Nonce=\"bar\"",values.get(2)); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetHeaders() throws Exception { Message m=control.createMock(Message.class); m.get(Message.PROTOCOL_HEADERS); EasyMock.expectLastCall().andReturn(createHeaders()); m.getContextualProperty("org.apache.cxf.http.header.split"); EasyMock.expectLastCall().andReturn("true").anyTimes(); control.replay(); HttpHeaders h=new HttpHeadersImpl(m); MultivaluedMap hs=h.getRequestHeaders(); List acceptValues=hs.get("Accept"); assertEquals(3,acceptValues.size()); assertEquals("text/bar;q=0.6",acceptValues.get(0)); assertEquals("text/*;q=1",acceptValues.get(1)); assertEquals("application/xml",acceptValues.get(2)); assertEquals(hs.getFirst("Content-Type"),"*/*"); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetHeaderWithQuotes3() throws Exception { Message m=control.createMock(Message.class); m.getContextualProperty("org.apache.cxf.http.header.split"); EasyMock.expectLastCall().andReturn("true"); m.get(Message.PROTOCOL_HEADERS); MetadataMap headers=createHeader("COMPLEX_HEADER","\"value with space\""); EasyMock.expectLastCall().andReturn(headers); control.replay(); HttpHeaders h=new HttpHeadersImpl(m); List values=h.getRequestHeader("COMPLEX_HEADER"); assertNotNull(values); assertEquals(1,values.size()); assertEquals("value with space",values.get(0)); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetLanguage() throws Exception { Message m=control.createMock(Message.class); m.get(Message.PROTOCOL_HEADERS); MetadataMap headers=createHeaders(); headers.putSingle(HttpHeaders.CONTENT_LANGUAGE,"en-US"); EasyMock.expectLastCall().andReturn(headers); control.replay(); HttpHeaders h=new HttpHeadersImpl(m); assertEquals("en_US",h.getLanguage().toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetCookiesWithComma() throws Exception { Message m=new MessageImpl(); Exchange ex=new ExchangeImpl(); ex.setInMessage(m); ex.put("org.apache.cxf.http.cookie.separator",","); m.setExchange(ex); MetadataMap headers=createHeaders(); headers.putSingle(HttpHeaders.COOKIE,"a=b,c=d"); m.put(Message.PROTOCOL_HEADERS,headers); HttpHeaders h=new HttpHeadersImpl(m); Map cookies=h.getCookies(); assertEquals(2,cookies.size()); assertEquals("b",cookies.get("a").getValue()); assertEquals("d",cookies.get("c").getValue()); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetMissingContentLength() throws Exception { Message m=new MessageImpl(); m.put(Message.PROTOCOL_HEADERS,new MetadataMap()); HttpHeaders h=new HttpHeadersImpl(m); assertEquals(-1,h.getLength()); }

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testUnmodifiableRequestHeaders() throws Exception { Message m=control.createMock(Message.class); m.getContextualProperty("org.apache.cxf.http.header.split"); EasyMock.expectLastCall().andReturn("true").anyTimes(); m.get(Message.PROTOCOL_HEADERS); MetadataMap headers=createHeader(HttpHeaders.ACCEPT_LANGUAGE,"en;q=0.7, en-gb;q=0.8, da"); EasyMock.expectLastCall().andReturn(headers); control.replay(); HttpHeaders h=new HttpHeadersImpl(m); List languages=h.getAcceptableLanguages(); assertEquals(3,languages.size()); languages.clear(); languages=h.getAcceptableLanguages(); assertEquals(3,languages.size()); MultivaluedMap rHeaders=h.getRequestHeaders(); List acceptL=rHeaders.get(HttpHeaders.ACCEPT_LANGUAGE); assertEquals(3,acceptL.size()); try { rHeaders.clear(); fail(); } catch ( UnsupportedOperationException ex) { } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetCookieWithAttributes() throws Exception { Message m=new MessageImpl(); m.setExchange(new ExchangeImpl()); MetadataMap headers=createHeaders(); headers.putSingle(HttpHeaders.COOKIE,"$Version=1;a=b"); m.put(Message.PROTOCOL_HEADERS,headers); HttpHeaders h=new HttpHeadersImpl(m); Map cookies=h.getCookies(); assertEquals(1,cookies.size()); Cookie cookie=cookies.get("a"); assertEquals("b",cookie.getValue()); assertEquals(1,cookie.getVersion()); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetHeader() throws Exception { Message m=control.createMock(Message.class); m.getContextualProperty("org.apache.cxf.http.header.split"); EasyMock.expectLastCall().andReturn("true"); m.get(Message.PROTOCOL_HEADERS); EasyMock.expectLastCall().andReturn(createHeaders()); control.replay(); HttpHeaders h=new HttpHeadersImpl(m); List acceptValues=h.getRequestHeader("Accept"); assertEquals(3,acceptValues.size()); assertEquals("text/bar;q=0.6",acceptValues.get(0)); assertEquals("text/*;q=1",acceptValues.get(1)); assertEquals("application/xml",acceptValues.get(2)); List contentValues=h.getRequestHeader("Content-Type"); assertEquals(1,contentValues.size()); assertEquals("*/*",contentValues.get(0)); List dateValues=h.getRequestHeader("Date"); assertEquals(1,dateValues.size()); assertEquals("Tue, 21 Oct 2008 17:00:00 GMT",dateValues.get(0)); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetHeaderString() throws Exception { Message m=new MessageImpl(); m.put(Message.PROTOCOL_HEADERS,createHeaders()); HttpHeaders h=new HttpHeadersImpl(m); String date=h.getHeaderString("Date"); assertEquals("Tue, 21 Oct 2008 17:00:00 GMT",date); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetMediaTypes() throws Exception { Message m=control.createMock(Message.class); m.get(Message.PROTOCOL_HEADERS); EasyMock.expectLastCall().andReturn(createHeaders()); control.replay(); HttpHeaders h=new HttpHeadersImpl(m); List acceptValues=h.getAcceptableMediaTypes(); assertEquals(3,acceptValues.size()); assertEquals("text/*;q=1",acceptValues.get(0).toString()); assertEquals("application/xml",acceptValues.get(1).toString()); assertEquals("text/bar;q=0.6",acceptValues.get(2).toString()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetDate() throws Exception { Message m=new MessageImpl(); m.put(Message.PROTOCOL_HEADERS,createHeaders()); HttpHeaders h=new HttpHeadersImpl(m); List dateValues=h.getRequestHeader("Date"); assertEquals(1,dateValues.size()); assertEquals("Tue, 21 Oct 2008 17:00:00 GMT",dateValues.get(0)); Date d=h.getDate(); String theDateValue=HttpUtils.getHttpDateFormat().format(d); assertEquals(theDateValue,"Tue, 21 Oct 2008 17:00:00 GMT"); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetContentLength() throws Exception { Message m=new MessageImpl(); m.put(Message.PROTOCOL_HEADERS,createHeaders()); HttpHeaders h=new HttpHeadersImpl(m); assertEquals(10,h.getLength()); }

Class: org.apache.cxf.jaxrs.impl.LinkBuilderImplTest

EqualityVerifier 
@Test public void testSelfLink() throws Exception { Link link=new LinkBuilderImpl().baseUri("http://localhost:8080/resource/1").rel("self").build(); assertEquals(";rel=\"self\"",link.toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testBuildManyRels() throws Exception { Link.Builder linkBuilder=new LinkBuilderImpl(); Link prevLink=linkBuilder.uri("http://example.com/page1").rel("1").rel("2").build(); assertEquals(";rel=\"1 2\"",prevLink.toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testSeveralAttributes() throws Exception { Link.Builder linkBuilder=new LinkBuilderImpl(); Link prevLink=linkBuilder.uri("http://example.com/page1").rel("previous").title("A title").build(); assertEquals(";rel=\"previous\";title=\"A title\"",prevLink.toString()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBuildObjects() throws Exception { StringBuilder path1=new StringBuilder().append("p1"); ByteArrayInputStream path2=new ByteArrayInputStream("p2".getBytes()){ @Override public String toString(){ return "p2"; } } ; URI path3=new URI("p3"); String expected="<" + "http://host.com:888/" + "p1/p2/p3"+ ">"; Link.Builder builder=Link.fromUri("http://host.com:888/" + "{x1}/{x2}/{x3}"); Link link=builder.build(path1,path2,path3); assertNotNull(link); assertEquals(link.toString(),expected); }

InternalCallVerifier EqualityVerifier 
@Test public void testBuild() throws Exception { Link.Builder linkBuilder=new LinkBuilderImpl(); Link prevLink=linkBuilder.uri("http://example.com/page1").rel("previous").build(); assertEquals(";rel=\"previous\"",prevLink.toString()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testBuildRelativized() throws Exception { Link.Builder linkBuilder=new LinkBuilderImpl(); URI base=URI.create("http://example.com/page2"); Link prevLink=linkBuilder.uri("http://example.com/page1").rel("previous").buildRelativized(base); assertEquals(";rel=\"previous\"",prevLink.toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testRelativeLink2() throws Exception { Link.Builder linkBuilder=Link.fromUri("/relative"); linkBuilder.baseUri("http://localhost:8080/base/path"); Link link=linkBuilder.rel("next").build(); assertEquals(";rel=\"next\"",link.toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testRelativeLink() throws Exception { Link.Builder linkBuilder=Link.fromUri("relative"); linkBuilder.baseUri("http://localhost:8080/base/path"); Link link=linkBuilder.rel("next").build(); assertEquals(";rel=\"next\"",link.toString()); }

Class: org.apache.cxf.jaxrs.impl.LinkHeaderProviderTest

InternalCallVerifier EqualityVerifier 
@Test public void testFromComplexString(){ Link l=Link.valueOf(";rel=next;title=\"Next Link\";type=text/xml;method=get"); assertEquals("http://bar",l.getUri().toString()); String rel=l.getRel(); assertEquals("next",rel); assertEquals("Next Link",l.getTitle()); assertEquals("text/xml",l.getType()); assertEquals("get",l.getParams().get("method")); }

EqualityVerifier 
@Test public void testFromSimpleString2(){ Link l=Link.valueOf(""); assertEquals("/",l.getUri().toString()); }

EqualityVerifier 
@Test public void testFromSimpleString(){ Link l=Link.valueOf(""); assertEquals("http://bar",l.getUri().toString()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testToString(){ String headerValue=";rel=next;title=\"Next Link\";type=text/xml;method=get"; String expected=";rel=\"next\";title=\"Next Link\";type=\"text/xml\";method=\"get\""; Link l=Link.valueOf(headerValue); String result=l.toString(); assertEquals(expected,result); }

Class: org.apache.cxf.jaxrs.impl.MediaTypeHeaderProviderTest

EqualityVerifier 
@Test public void testShortWildcardWithParameters2(){ MediaType m=MediaType.valueOf("* ;q=0.2"); assertEquals("Media type was not parsed correctly",m,new MediaType("*","*",Collections.singletonMap("q","0.2"))); }

EqualityVerifier 
@Test public void testSimpleType(){ MediaType m=MediaType.valueOf("text/html"); assertEquals("Media type was not parsed correctly",m,new MediaType("text","html")); assertEquals("Media type was not parsed correctly",MediaType.valueOf("text/html "),new MediaType("text","html")); }

EqualityVerifier 
@Test public void testSimpleToString(){ MediaTypeHeaderProvider provider=new MediaTypeHeaderProvider(); assertEquals("simple media type is not serialized","text/plain",provider.toString(new MediaType("text","plain"))); }

InternalCallVerifier EqualityVerifier 
@Test public void testTypeWithExtendedParameters(){ MediaType mt=MediaType.valueOf("multipart/related;type=application/dicom+xml"); assertEquals("multipart",mt.getType()); assertEquals("related",mt.getSubtype()); Map params2=mt.getParameters(); assertEquals(1,params2.size()); assertEquals("application/dicom+xml",params2.get("type")); }

EqualityVerifier 
@Test public void testShortWildcardWithParameters3(){ MediaType m=MediaType.valueOf("*; q=.2"); assertEquals("Media type was not parsed correctly",m,new MediaType("*","*",Collections.singletonMap("q",".2"))); }

InternalCallVerifier EqualityVerifier 
@Test public void testTypeWithExtendedParametersQuote(){ MediaType mt=MediaType.valueOf("multipart/related;type=\"application/dicom+xml\""); assertEquals("multipart",mt.getType()); assertEquals("related",mt.getSubtype()); Map params2=mt.getParameters(); assertEquals(1,params2.size()); assertEquals("\"application/dicom+xml\"",params2.get("type")); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testHeaderFileName(){ String fileName="version_2006(3).pdf"; String header="application/octet-stream; name=\"%s\""; String value=String.format(header,fileName); MediaTypeHeaderProvider provider=new MediaTypeHeaderProvider(); MediaType mt=provider.fromString(value); assertEquals("application",mt.getType()); assertEquals("octet-stream",mt.getSubtype()); Map params=mt.getParameters(); assertEquals(1,params.size()); assertEquals("\"version_2006(3).pdf\"",params.get("name")); }

EqualityVerifier 
@Test public void testShortWildcardWithParameters(){ MediaType m=MediaType.valueOf("*;q=0.2"); assertEquals("Media type was not parsed correctly",m,new MediaType("*","*",Collections.singletonMap("q","0.2"))); }

InternalCallVerifier EqualityVerifier 
@Test public void testTypeWithExtendedAndBoundaryParameter(){ MediaType mt=MediaType.valueOf("multipart/related; type=application/dicom+xml; boundary=\"uuid:b9aecb2a-ab37-48d6-a1cd-b2f4f7fa63cb\""); assertEquals("multipart",mt.getType()); assertEquals("related",mt.getSubtype()); Map params2=mt.getParameters(); assertEquals(2,params2.size()); assertEquals("\"uuid:b9aecb2a-ab37-48d6-a1cd-b2f4f7fa63cb\"",params2.get("boundary")); assertEquals("application/dicom+xml",params2.get("type")); }

InternalCallVerifier EqualityVerifier 
@Test public void testTypeWithParameters(){ MediaType mt=MediaType.valueOf("text/html;q=1234;b=4321"); assertEquals("text",mt.getType()); assertEquals("html",mt.getSubtype()); Map params2=mt.getParameters(); assertEquals(2,params2.size()); assertEquals("1234",params2.get("q")); assertEquals("4321",params2.get("b")); }

EqualityVerifier 
@Test public void testShortWildcard(){ MediaType m=MediaType.valueOf("*"); assertEquals("Media type was not parsed correctly",m,new MediaType("*","*")); }

EqualityVerifier 
@Test public void testComplexToString(){ MediaTypeHeaderProvider provider=new MediaTypeHeaderProvider(); Map params=new LinkedHashMap(); params.put("foo","bar"); params.put("q","0.2"); assertEquals("complex media type is not serialized","text/plain;foo=bar;q=0.2",provider.toString(new MediaType("text","plain",params))); }

Class: org.apache.cxf.jaxrs.impl.MetadataMapTest

InternalCallVerifier EqualityVerifier 
@Test public void testPutSingleNullKeyCaseSensitive(){ MetadataMap m=new MetadataMap(false,true); m.putSingle(null,"null"); m.putSingle(null,"null2"); assertEquals(1,m.get(null).size()); assertEquals("null2",m.getFirst(null)); }

InternalCallVerifier EqualityVerifier 
@Test public void testCopyAndUpdate(){ MetadataMap m=new MetadataMap(); m.add("baz","bar"); MetadataMap m2=new MetadataMap(m); m.remove("baz"); m.add("baz","foo"); assertEquals("bar",m2.getFirst("baz")); assertEquals("foo",m.getFirst("baz")); }

InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testPutSingleNullKeyCaseSensitive2(){ MetadataMap map=new MetadataMap(false,true); Object obj1=new Object(); Object obj2=new Object(); map.putSingle("key",obj1); map.putSingle("key",obj2); map.putSingle(null,obj2); map.putSingle(null,obj1); assertEquals(2,map.size()); assertEquals(1,map.get(null).size()); assertSame(map.getFirst("key"),obj2); assertSame(map.getFirst(null),obj1); }

InternalCallVerifier EqualityVerifier 
@Test public void testRemoveCaseInsensitive(){ MetadataMap m=new MetadataMap(false,true); List value1=new ArrayList(); value1.add("bar"); value1.add("foo"); m.put("baz",value1); m.putSingle("baz","clazz"); assertEquals(1,m.size()); m.remove("Baz"); assertEquals(0,m.size()); }

InternalCallVerifier EqualityVerifier 
@Test public void testAddAndGetFirst(){ MetadataMap m=new MetadataMap(); m.add("baz","bar"); List value=m.get("baz"); assertEquals("Only a single value should be in the list",1,value.size()); assertEquals("Value is wrong","bar",value.get(0)); m.add("baz","foo"); value=m.get("baz"); assertEquals("Two values should be in the list",2,value.size()); assertEquals("Value1 is wrong","bar",value.get(0)); assertEquals("Value2 is wrong","foo",value.get(1)); assertEquals("GetFirst value is wrong","bar",m.getFirst("baz")); }

InternalCallVerifier EqualityVerifier 
@Test public void testAddFirst(){ MetadataMap m=new MetadataMap(); m.addFirst("baz","foo"); List values=m.get("baz"); assertEquals(1,values.size()); assertEquals("foo",values.get(0)); m.addFirst("baz","clazz"); values=m.get("baz"); assertEquals(2,values.size()); assertEquals("clazz",values.get(0)); assertEquals("foo",values.get(1)); }

InternalCallVerifier EqualityVerifier 
@Test public void testAddFirstUnmodifiableListFirst(){ MetadataMap m=new MetadataMap(); m.put("baz",Arrays.asList("foo")); List values=m.get("baz"); assertEquals(1,values.size()); assertEquals("foo",values.get(0)); m.addFirst("baz","clazz"); values=m.get("baz"); assertEquals(2,values.size()); assertEquals("clazz",values.get(0)); assertEquals("foo",values.get(1)); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testCompareIgnoreValueOrder(){ MetadataMap m=new MetadataMap(); m.add("baz","bar1"); m.add("baz","bar2"); List values=m.get("baz"); assertEquals("bar1",values.get(0)); assertEquals("bar2",values.get(1)); MetadataMap m2=new MetadataMap(); m2.add("baz","bar2"); m2.add("baz","bar1"); values=m2.get("baz"); assertEquals("bar2",values.get(0)); assertEquals("bar1",values.get(1)); assertTrue(m.equalsIgnoreValueOrder(m2)); assertTrue(m.equalsIgnoreValueOrder(m)); assertTrue(m2.equalsIgnoreValueOrder(m)); MetadataMap m3=new MetadataMap(); m3.add("baz","bar1"); assertFalse(m.equalsIgnoreValueOrder(m3)); assertFalse(m2.equalsIgnoreValueOrder(m3)); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testPutSingleCaseInsensitive(){ MetadataMap m=new MetadataMap(false,true); List value1=new ArrayList(); value1.add("bar"); value1.add("foo"); m.put("baz",value1); m.putSingle("baz","clazz"); assertEquals(1,m.size()); List value2=m.get("baz"); assertEquals("Only a single value should be in the list",1,value2.size()); assertEquals("Value is wrong","clazz",value2.get(0)); m.putSingle("Baz","clazz2"); assertEquals(1,m.size()); value2=m.get("baz"); assertEquals("Only a single value should be in the list",1,value2.size()); assertEquals("Value is wrong","clazz2",value2.get(0)); assertTrue(m.containsKey("Baz")); assertTrue(m.containsKey("baz")); }

InternalCallVerifier EqualityVerifier 
@Test public void testPutAllCaseInsensitive(){ MetadataMap m=new MetadataMap(false,true); List value1=new ArrayList(); value1.add("bar"); value1.add("foo"); m.put("baz",value1); assertEquals(1,m.size()); List values=m.get("baz"); assertEquals(2,values.size()); assertEquals("bar",values.get(0)); assertEquals("foo",values.get(1)); MetadataMap m2=new MetadataMap(false,true); List value2=new ArrayList(); value2.add("bar2"); value2.add("foo2"); m2.put("BaZ",value2); m.putAll(m2); assertEquals(1,m.size()); values=m.get("Baz"); assertEquals(2,values.size()); assertEquals("bar2",values.get(0)); assertEquals("foo2",values.get(1)); }

InternalCallVerifier EqualityVerifier 
@Test public void testAddAll(){ MetadataMap m=new MetadataMap(); List values=new ArrayList(); values.add("foo"); m.addAll("baz",values); values=m.get("baz"); assertEquals(1,values.size()); assertEquals("foo",values.get(0)); m.addAll("baz",Collections.singletonList("foo2")); values=m.get("baz"); assertEquals(2,values.size()); assertEquals("foo",values.get(0)); assertEquals("foo2",values.get(1)); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testGetCaseInsensitive(){ MetadataMap m=new MetadataMap(); m.add("Baz","bar"); MetadataMap m2=new MetadataMap(m,true,true); assertEquals("bar",m2.getFirst("baZ")); assertEquals("bar",m2.getFirst("Baz")); assertTrue(m2.containsKey("BaZ")); assertTrue(m2.containsKey("Baz")); List values=m2.get("baz"); assertEquals(1,values.size()); assertEquals("bar",values.get(0).toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testPutSingleNullKey(){ MetadataMap m=new MetadataMap(); m.putSingle(null,"null"); m.putSingle(null,"null2"); assertEquals(1,m.get(null).size()); assertEquals("null2",m.getFirst(null)); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testPutSingle(){ MetadataMap m=new MetadataMap(); List value1=new ArrayList(); value1.add("bar"); value1.add("foo"); m.put("baz",value1); m.putSingle("baz","clazz"); List value2=m.get("baz"); assertEquals("Only a single value should be in the list",1,value2.size()); assertEquals("Value is wrong","clazz",value2.get(0)); assertNull(m.get("baZ")); }

Class: org.apache.cxf.jaxrs.impl.NewCookieHeaderProviderTest

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testFromComplexStringWithExpiresAndHttpOnly(){ NewCookie c=NewCookie.valueOf("foo=bar;Comment=comment;Path=path;Max-Age=10;Domain=domain;Secure;" + "Expires=Wed, 09 Jun 2021 10:18:14 GMT;HttpOnly;Version=1"); assertTrue("bar".equals(c.getValue()) && "foo".equals(c.getName())); assertTrue(1 == c.getVersion() && "path".equals(c.getPath()) && "domain".equals(c.getDomain()) && "comment".equals(c.getComment()) && c.isSecure() && c.isHttpOnly() && 10 == c.getMaxAge()); Date d=c.getExpiry(); assertNotNull(d); assertEquals("Wed, 09 Jun 2021 10:18:14 GMT",HttpUtils.toHttpDate(d)); }

EqualityVerifier 
@Test public void testToString(){ NewCookie c=new NewCookie("foo","bar","path","domain","comment",2,true); assertEquals("foo=bar;Comment=comment;Domain=domain;Max-Age=2;Path=path;Secure;Version=1",c.toString()); }

EqualityVerifier 
@Test public void testToStringWithSpecialChar(){ NewCookie c=new NewCookie("foo","bar (space)<>[]","/path?path","domain.com","comment@comment:,",2,true); assertEquals("foo=\"bar (space)<>[]\";Comment=\"comment@comment:,\";Domain=domain.com;Max-Age=2;" + "Path=\"/path?path\";Secure;Version=1",c.toString()); }

Class: org.apache.cxf.jaxrs.impl.PathSegmentImplTest

InternalCallVerifier EqualityVerifier 
@Test public void testPlainPathSegment(){ PathSegment ps=new PathSegmentImpl("bar"); assertEquals("bar",ps.getPath()); assertEquals(0,ps.getMatrixParameters().size()); }

InternalCallVerifier EqualityVerifier 
@Test public void testPathSegmentWithDecodedMatrixParams(){ PathSegment ps=new PathSegmentImpl("bar%20foo;a=1%202"); assertEquals("bar foo",ps.getPath()); MultivaluedMap params=ps.getMatrixParameters(); assertEquals(1,params.size()); assertEquals(1,params.get("a").size()); assertEquals("1 2",params.get("a").get(0)); }

InternalCallVerifier EqualityVerifier 
@Test public void testPathSegmentWithMatrixParams(){ PathSegment ps=new PathSegmentImpl("bar;a=1;a=2;b=3%202",false); assertEquals("bar",ps.getPath()); MultivaluedMap params=ps.getMatrixParameters(); assertEquals(2,params.size()); assertEquals(2,params.get("a").size()); assertEquals("1",params.get("a").get(0)); assertEquals("2",params.get("a").get(1)); assertEquals("3%202",params.getFirst("b")); }

Class: org.apache.cxf.jaxrs.impl.RequestImplTest

EqualityVerifier 
@Test public void testStarEtagsIfNotMatch(){ metadata.putSingle(HttpHeaders.IF_NONE_MATCH,"*"); ResponseBuilder rb=new RequestImpl(m).evaluatePreconditions(new EntityTag("123")); assertEquals("Precondition must not be met",304,rb.build().getStatus()); }

EqualityVerifier 
@Test public void testEtagsIfNotMatch(){ metadata.putSingle(HttpHeaders.IF_NONE_MATCH,"\"123\""); ResponseBuilder rb=new RequestImpl(m).evaluatePreconditions(new EntityTag("123")); assertEquals("Precondition must not be met",304,rb.build().getStatus()); }

EqualityVerifier 
@Test public void testStrictEtagsPreconditionNotMet(){ metadata.putSingle("If-Match",new EntityTag("123",true).toString()); ResponseBuilder rb=new RequestImpl(m).evaluatePreconditions(new EntityTag("123")); assertEquals("Precondition must not be met, strict comparison is required",412,rb.build().getStatus()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAfterDate() throws Exception { metadata.putSingle("If-Modified-Since","Tue, 21 Oct 2008 14:00:00 GMT"); Date lastModified=new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz",Locale.ENGLISH).parse("Mon, 20 Oct 2008 14:00:00 GMT"); ResponseBuilder rb=new RequestImpl(m).evaluatePreconditions(lastModified); assertNotNull("Precondition is not met",rb); Response r=rb.build(); assertEquals("If-Modified-Since precondition was not met",304,r.getStatus()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testWeakEtags(){ metadata.putSingle("If-Match",new EntityTag("123",true).toString()); ResponseBuilder rb=new RequestImpl(m).evaluatePreconditions(new EntityTag("123")); assertNotNull("Strict compararison is required",rb); Response r=rb.build(); assertEquals("If-Match precondition was not met",412,r.getStatus()); assertEquals("Response should include ETag","\"123\"",r.getMetadata().getFirst("ETag").toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testBeforeDateIfNotModified() throws Exception { metadata.putSingle(HttpHeaders.IF_UNMODIFIED_SINCE,"Mon, 20 Oct 2008 14:00:00 GMT"); Date serverDate=new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz",Locale.ENGLISH).parse("Tue, 21 Oct 2008 14:00:00 GMT"); ResponseBuilder rb=new RequestImpl(m).evaluatePreconditions(serverDate); assertEquals("Precondition must not be met",412,rb.build().getStatus()); }

InternalCallVerifier EqualityVerifier 
@Test public void testStarEtagsIfNotMatchPut(){ metadata.putSingle(HttpHeaders.IF_NONE_MATCH,"*"); m.put(Message.HTTP_REQUEST_METHOD,"PUT"); ResponseBuilder rb=new RequestImpl(m).evaluatePreconditions(new EntityTag("123")); assertEquals("Precondition must not be met",412,rb.build().getStatus()); }

EqualityVerifier 
@Test public void testIfNotMatchAndLastModified(){ metadata.putSingle(HttpHeaders.IF_NONE_MATCH,"1"); ResponseBuilder rb=new RequestImpl(m).evaluatePreconditions(new Date(),new EntityTag("1")); assertEquals("Precondition must not be met",304,rb.build().getStatus()); }

EqualityVerifier 
@Test public void testGetMethod(){ assertEquals("Wrong method","GET",new RequestImpl(m).getMethod()); }

Class: org.apache.cxf.jaxrs.impl.RequestPreprocessorTest

EqualityVerifier 
@Test public void testMethodOverride(){ Message m=mockMessage("http://localhost:8080","/bar","bar","POST","GET"); RequestPreprocessor sqh=new RequestPreprocessor(); sqh.preprocess(m,new UriInfoImpl(m,null)); assertEquals("GET",m.get(Message.HTTP_REQUEST_METHOD)); }

InternalCallVerifier EqualityVerifier 
@Test public void testTypeQuery(){ Message m=mockMessage("http://localhost:8080","/bar","_type=xml","POST"); RequestPreprocessor sqh=new RequestPreprocessor(); sqh.preprocess(m,new UriInfoImpl(m,null)); assertEquals("POST",m.get(Message.HTTP_REQUEST_METHOD)); assertEquals("application/xml",m.get(Message.ACCEPT_CONTENT_TYPE)); }

EqualityVerifier 
@Test public void testMethodQuery(){ Message m=mockMessage("http://localhost:8080","/bar","_method=GET","POST"); RequestPreprocessor sqh=new RequestPreprocessor(); sqh.preprocess(m,new UriInfoImpl(m,null)); assertEquals("GET",m.get(Message.HTTP_REQUEST_METHOD)); }

Class: org.apache.cxf.jaxrs.impl.ResponseBuilderImplTest

APIUtilityVerifier EqualityVerifier 
@Test public void testEntityAnnotations() throws Exception { MetadataMap m=new MetadataMap(); Annotation[] annotations=new Annotation[1]; Annotation produces=new Produces(){ @Override public Class annotationType(){ return Produces.class; } @Override public String[] value(){ return new String[]{"text/turtle"}; } } ; annotations[0]=produces; Response response=Response.ok().entity("<> a <#test>",annotations).build(); checkBuild(response,200,"<> a <#test>",m); assertArrayEquals(annotations,((ResponseImpl)response).getEntityAnnotations()); }

EqualityVerifier 
@Test public void testValidStatus(){ assertEquals(100,Response.status(100).build().getStatus()); assertEquals(101,Response.status(101).build().getStatus()); assertEquals(200,Response.status(200).build().getStatus()); assertEquals(599,Response.status(599).build().getStatus()); assertEquals(598,Response.status(598).build().getStatus()); }

InternalCallVerifier EqualityVerifier 
@Test public void testEntityTag(){ Response r=Response.ok().tag(new EntityTag("foo")).build(); String eTag=r.getMetadata().getFirst("ETag").toString(); assertEquals("\"foo\"",eTag); }

InternalCallVerifier EqualityVerifier 
@Test public void testTagStringWithQuotes(){ Response r=Response.ok().tag("\"foo\"").build(); String eTag=r.getMetadata().getFirst("ETag").toString(); assertEquals("\"foo\"",eTag); }

EqualityVerifier 
@Test public void testStatusNotSetEntitySet() throws Exception { assertEquals(200,new ResponseBuilderImpl().entity("").build().getStatus()); }

EqualityVerifier 
@Test public void testStatusNotSetNoEntity() throws Exception { assertEquals(204,new ResponseBuilderImpl().build().getStatus()); }

InternalCallVerifier EqualityVerifier 
@Test public void testTagString(){ Response r=Response.ok().tag("foo").build(); String eTag=r.getMetadata().getFirst("ETag").toString(); assertEquals("\"foo\"",eTag); }

InternalCallVerifier EqualityVerifier 
@Test public void testEntityTag2(){ Response r=Response.ok().tag(new EntityTag("\"foo\"")).build(); String eTag=r.getMetadata().getFirst("ETag").toString(); assertEquals("\"foo\"",eTag); }

EqualityVerifier 
@Test public void testStatusSet() throws Exception { assertEquals(200,Response.ok().build().getStatus()); assertEquals(200,new ResponseBuilderImpl().status(200).build().getStatus()); }

Class: org.apache.cxf.jaxrs.impl.ResponseImplTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testStatuInfoForOKStatus(){ StatusType si=new ResponseImpl(200,"").getStatusInfo(); assertNotNull(si); assertEquals(200,si.getStatusCode()); assertEquals(Status.Family.SUCCESSFUL,si.getFamily()); assertEquals("OK",si.getReasonPhrase()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testReadBufferedStaxUtils() throws Exception { ResponseImpl r=new ResponseImpl(200); Source responseSource=readResponseSource(r); Document doc=StaxUtils.read(responseSource); assertEquals("Response",doc.getDocumentElement().getLocalName()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testStatuInfoForClientErrorStatus(){ StatusType si=new ResponseImpl(400,"").getStatusInfo(); assertNotNull(si); assertEquals(400,si.getStatusCode()); assertEquals(Status.Family.CLIENT_ERROR,si.getFamily()); assertEquals("Bad Request",si.getReasonPhrase()); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetMediaType(){ ResponseImpl ri=new ResponseImpl(200); MetadataMap meta=new MetadataMap(); meta.add(HttpHeaders.CONTENT_TYPE,"text/xml"); ri.addMetadata(meta); assertEquals("text/xml",ri.getMediaType().toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetLanguage(){ ResponseImpl ri=new ResponseImpl(200); MetadataMap meta=new MetadataMap(); meta.add(HttpHeaders.CONTENT_LANGUAGE,"en-US"); ri.addMetadata(meta); assertEquals("en_US",ri.getLanguage().toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testLocation(){ ResponseImpl ri=new ResponseImpl(200); MetadataMap meta=new MetadataMap(); meta.add(HttpHeaders.LOCATION,"http://localhost:8080"); ri.addMetadata(meta); assertEquals("http://localhost:8080",ri.getLocation().toString()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testStatuInfoForClientErrorStatus2(){ StatusType si=new ResponseImpl(499,"").getStatusInfo(); assertNotNull(si); assertEquals(499,si.getStatusCode()); assertEquals(Status.Family.CLIENT_ERROR,si.getFamily()); assertEquals("",si.getReasonPhrase()); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetCookies(){ ResponseImpl ri=new ResponseImpl(200); MetadataMap meta=new MetadataMap(); meta.add("Set-Cookie",NewCookie.valueOf("a=b")); meta.add("Set-Cookie",NewCookie.valueOf("c=d")); ri.addMetadata(meta); Map cookies=ri.getCookies(); assertEquals(2,cookies.size()); assertEquals("a=b;Version=1",cookies.get("a").toString()); assertEquals("c=d;Version=1",cookies.get("c").toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetContentLength(){ ResponseImpl ri=new ResponseImpl(200); MetadataMap meta=new MetadataMap(); ri.addMetadata(meta); assertEquals(-1,ri.getLength()); meta.add("Content-Length","10"); assertEquals(10,ri.getLength()); }

InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testResourceImpl(){ String entity="bar"; ResponseImpl ri=new ResponseImpl(200,entity); assertEquals("Wrong status",ri.getStatus(),200); assertSame("Wrong entity",entity,ri.getEntity()); MetadataMap meta=new MetadataMap(); ri.addMetadata(meta); ri.getMetadata(); assertSame("Wrong metadata",meta,ri.getMetadata()); assertSame("Wrong metadata",meta,ri.getHeaders()); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetHeaderStrings(){ ResponseImpl ri=new ResponseImpl(200); MetadataMap meta=new MetadataMap(); meta.add("Set-Cookie",NewCookie.valueOf("a=b")); ri.addMetadata(meta); MultivaluedMap headers=ri.getStringHeaders(); assertEquals(1,headers.size()); assertEquals("a=b;Version=1",headers.getFirst("Set-Cookie")); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetHeaderString(){ ResponseImpl ri=new ResponseImpl(200); MetadataMap meta=new MetadataMap(); ri.addMetadata(meta); assertNull(ri.getHeaderString("a")); meta.putSingle("a","aValue"); assertEquals("aValue",ri.getHeaderString("a")); meta.add("a","aValue2"); assertEquals("aValue,aValue2",ri.getHeaderString("a")); }

APIUtilityVerifier EqualityVerifier 
@Test public void testReadBufferedStaxSource() throws Exception { ResponseImpl r=new ResponseImpl(200); Source responseSource=readResponseSource(r); Transformer trans=TransformerFactory.newInstance().newTransformer(); DOMResult res=new DOMResult(); trans.transform(responseSource,res); Document doc=(Document)res.getNode(); assertEquals("Response",doc.getDocumentElement().getLocalName()); }

InternalCallVerifier EqualityVerifier 
@Test public void testEntityTag(){ ResponseImpl ri=new ResponseImpl(200); MetadataMap meta=new MetadataMap(); meta.add(HttpHeaders.ETAG,"1234"); ri.addMetadata(meta); assertEquals("\"1234\"",ri.getEntityTag().toString()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testReadEntityWithNullOutMessage(){ final String str="ouch"; Response response=Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(str).build(); Assert.assertEquals(str,response.readEntity(String.class)); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetLinks(){ ResponseImpl ri=new ResponseImpl(200); MetadataMap meta=new MetadataMap(); ri.addMetadata(meta); assertFalse(ri.hasLink("next")); assertNull(ri.getLink("next")); assertFalse(ri.hasLink("prev")); assertNull(ri.getLink("prev")); meta.add(HttpHeaders.LINK,";rel=next"); meta.add(HttpHeaders.LINK,";rel=prev"); assertTrue(ri.hasLink("next")); Link next=ri.getLink("next"); assertNotNull(next); assertTrue(ri.hasLink("prev")); Link prev=ri.getLink("prev"); assertNotNull(prev); Set links=ri.getLinks(); assertTrue(links.contains(next)); assertTrue(links.contains(prev)); assertEquals("http://localhost:8080/next;a=b",next.getUri().toString()); assertEquals("next",next.getRel()); assertEquals("http://prev",prev.getUri().toString()); assertEquals("prev",prev.getRel()); }

Class: org.apache.cxf.jaxrs.impl.SecurityContextImplTest

InternalCallVerifier EqualityVerifier 
@Test public void testAuthenticationScheme(){ Message m=new MessageImpl(); Map> requestHeaders=new TreeMap>(String.CASE_INSENSITIVE_ORDER); List values=new ArrayList(); values.add("Digest realm=\"custom\""); requestHeaders.put("Authorization",values); m.put(Message.PROTOCOL_HEADERS,requestHeaders); String scheme=new SecurityContextImpl(m).getAuthenticationScheme(); assertEquals("Digest",scheme); }

Class: org.apache.cxf.jaxrs.impl.UriBuilderImplTest

EqualityVerifier 
@Test public void testFromUriWithMatrix(){ String expected="http://localhost:8080/name;a=b"; URI uri=UriBuilder.fromUri("http://localhost:8080/name;a=b").build(); assertEquals(expected,uri.toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testBuildWithNonEncodedSubstitutionValue6(){ UriBuilder ub=UriBuilder.fromPath("/"); URI uri=ub.path("%").build(); assertEquals("/%25",uri.toString()); uri=ub.replacePath("/%/{token}").build("{}"); assertEquals("/%25/%7B%7D",uri.toString()); }

EqualityVerifier 
@Test public void testPathTrailingSlash() throws Exception { URI uri=new URI("http://bar"); URI newUri=new UriBuilderImpl(uri).path("/").build(); assertEquals("URI is not built correctly","http://bar/",newUri.toString()); }

EqualityVerifier 
@Test public void testReplaceNullPath() throws Exception { URI uri=new URI("http://foo/bar/baz;m1=m1value"); URI newUri=new UriBuilderImpl(uri).replacePath(null).build(); assertEquals("URI is not built correctly","http://foo",newUri.toString()); }

EqualityVerifier 
@Test public void testQueryParamVal() throws Exception { URI uri=new URI("http://foo/bar?p1=v1"); URI newUri=new UriBuilderImpl(uri).queryParam("p2","v2").build(); assertEquals("URI is not built correctly",new URI("http://foo/bar?p1=v1&p2=v2"),newUri); }

InternalCallVerifier EqualityVerifier 
@Test public void testBuildWithNonEncodedSubstitutionValue7(){ UriBuilder ub=UriBuilder.fromPath("/"); URI uri=ub.replaceQueryParam("a","%").buildFromEncoded(); assertEquals("/?a=%25",uri.toString()); uri=ub.replaceQueryParam("a2","{token}").buildFromEncoded("{}"); assertEquals("/?a=%25&a2=%7B%7D",uri.toString()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testResolveTemplate5(){ Map templs=new HashMap(); templs.put("a","1"); templs.put("b","2"); URI uri; uri=UriBuilder.fromPath("/{a}/{b}").queryParam("c","{c}").resolveTemplates(templs).build("3"); assertEquals("/1/2?c=3",uri.toString()); }

EqualityVerifier 
@Test public void testReplaceQueryWithNull2(){ String expected="http://localhost:8080"; URI uri=UriBuilder.fromPath("http://localhost:8080").queryParam("name","x=","y?","x y","&").replaceQuery(null).build(); assertEquals(expected,uri.toString()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testAddMatrixToEmptyPath() throws Exception { String name="name"; String expected="http://localhost:8080;name=x;name=y"; URI uri=UriBuilder.fromPath("http://localhost:8080").matrixParam(name,"x","y").build(); assertEquals(expected,uri.toString()); }

EqualityVerifier 
@Test public void testNullScheme(){ String expected="localhost:8080"; URI uri=UriBuilder.fromUri("http://localhost:8080").scheme(null).build(); assertEquals(expected,uri.toString()); }

EqualityVerifier 
@Test public void testReplacePath() throws Exception { URI uri=new URI("http://foo/bar/baz;m1=m1value"); URI newUri=new UriBuilderImpl(uri).replacePath("/newpath").build(); assertEquals("URI is not built correctly","http://foo/newpath",newUri.toString()); }

EqualityVerifier 
@Test public void testFromEncodedDuplicateVarReplacePath(){ String expected="http://localhost:8080/1/2/3/1"; URI uri=UriBuilder.fromPath("").replacePath("http://localhost:8080").path("/{a}/{b}/{c}/{a}").buildFromEncoded("1","2","3"); assertEquals(expected,uri.toString()); }

EqualityVerifier 
@Test public void testResolveTemplateFromEncoded(){ URI uri; uri=UriBuilder.fromPath("/{a}").resolveTemplate("a","%20 ").buildFromEncoded(); assertEquals("/%20%20",uri.toString()); }

EqualityVerifier 
@Test public void testPathParamSpaceBuildEncoded(){ String expected="http://localhost:8080/name/%20"; URI uri=UriBuilder.fromUri("http://localhost:8080").path("name/%20").buildFromEncoded(); assertEquals(expected,uri.toString()); }

EqualityVerifier 
@Test public void testResolveTemplate4(){ URI uri; uri=UriBuilder.fromPath("/{a}/{b}").queryParam("c","{c}").resolveTemplate("a","1").build("2","3"); assertEquals("/1/2?c=3",uri.toString()); }

EqualityVerifier 
@Test public void testReplaceMatrixParamExistingMulti() throws Exception { URI uri=new URI("http://foo/bar;p1=v1;p2=v2"); URI newUri=new UriBuilderImpl(uri).replaceMatrixParam("p1","nv1","nv2").build(); assertEquals("URI is not built correctly",new URI("http://foo/bar;p1=nv1;p1=nv2;p2=v2"),newUri); }

EqualityVerifier 
@Test public void testFragmentTemplate(){ String expected="abc#xyz"; URI uri=UriBuilder.fromPath("{arg1}").fragment("{arg2}").build("abc","xyz"); assertEquals(expected,uri.toString()); }

EqualityVerifier 
@Test public void testQueryParamSpaceBuild(){ String expected="http://localhost:8080?name=%20"; URI uri=UriBuilder.fromUri("http://localhost:8080").queryParam("name","%20").build(); assertEquals(expected,uri.toString()); }

EqualityVerifier 
@Test public void testReplaceQueryParamValNull() throws Exception { URI uri=new URI("http://foo/bar?p1=v1&p2=v2&p1=v3"); URI newUri=new UriBuilderImpl(uri).replaceQueryParam("p1",(Object)null).build(); assertEquals("URI is not built correctly",new URI("http://foo/bar?p2=v2"),newUri); }

EqualityVerifier 
@Test public void testReplaceMatrixNull() throws Exception { URI uri=new URI("http://foo/bar;p1=v1;p2=v2"); URI newUri=new UriBuilderImpl(uri).replaceMatrix(null).build(); assertEquals("URI is not built correctly",new URI("http://foo/bar"),newUri); }

InternalCallVerifier EqualityVerifier 
@Test public void testBuildWithNonEncodedSubstitutionValue8(){ UriBuilder ub=UriBuilder.fromPath("/"); URI uri=ub.replaceQueryParam("a","%").build(); assertEquals("/?a=%25",uri.toString()); uri=ub.replaceQueryParam("a2","{token}").build("{}"); assertEquals("/?a=%25&a2=%7B%7D",uri.toString()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testSegments(){ String path1="ab"; String[] path2={"a1","x/y","3b "}; String expected="ab/a1/x%2Fy/3b%20"; URI uri=UriBuilder.fromPath(path1).segment(path2).build(); assertEquals(expected,uri.toString()); }

EqualityVerifier 
@Test public void testClone() throws Exception { URI uri=new URI("http://bar"); URI newUri=new UriBuilderImpl(uri).clone().build(); assertEquals("URI is not built correctly","http://bar",newUri.toString()); }

EqualityVerifier 
@Test public void testEncodedPathWithTwoAsteriscs() throws Exception { URI uri=new URI("http://bar/foo/"); URI newUri=new UriBuilderImpl(uri).path("**").buildFromEncoded(); assertEquals("URI is not built correctly","http://bar/foo/**",newUri.toString()); }

EqualityVerifier 
@Test public void testReplaceParamAndEncodeQueryParamFromBuild() throws Exception { String expectedValue="http://localhost:8080?name=x&name=y&name=y+x&name=x%25y&name=%20"; URI uri=UriBuilder.fromPath("http://localhost:8080").queryParam("name","x=","y?","x y","&").replaceQueryParam("name","x","y","y x","x%y","%20").build(); assertEquals(expectedValue,uri.toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testBuildFromEncodedMapMultipleTimes() throws Exception { Map maps=new HashMap(); maps.put("x","x%yz"); maps.put("y","/path-absolute/test1"); maps.put("z","fred@example.com"); maps.put("w","path-rootless/test2"); Map maps1=new HashMap(); maps1.put("x","x%20yz"); maps1.put("y","/path-absolute/test1"); maps1.put("z","fred@example.com"); maps1.put("w","path-rootless/test2"); Map maps2=new HashMap(); maps2.put("x","x%yz"); maps2.put("y","/path-absolute/test1"); maps2.put("z","fred@example.com"); maps2.put("w","path-rootless/test2"); maps2.put("v","xyz"); String expectedPath="path-rootless/test2/x%25yz//path-absolute/test1/fred@example.com/x%25yz"; String expectedPath1="path-rootless/test2/x%20yz//path-absolute/test1/fred@example.com/x%20yz"; String expectedPath2="path-rootless/test2/x%25yz//path-absolute/test1/fred@example.com/x%25yz"; UriBuilder ub=UriBuilder.fromPath("").path("{w}/{x}/{y}/{z}/{x}"); URI uri=ub.buildFromEncodedMap(maps); assertEquals(expectedPath,uri.getRawPath()); uri=ub.buildFromEncodedMap(maps1); assertEquals(expectedPath1,uri.getRawPath()); uri=ub.buildFromEncodedMap(maps2); assertEquals(expectedPath2,uri.getRawPath()); }

EqualityVerifier 
@Test public void testResolveTemplate3(){ URI uri; uri=UriBuilder.fromPath("/{a}/{b}").resolveTemplate("b","1").build("2"); assertEquals("/2/1",uri.toString()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testBuildFromMapValuesPctEncoded() throws Exception { URI uri=new URI("http://zzz"); Map map=new HashMap(); map.put("a","foo%25"); map.put("b","bar%"); Map immutable=Collections.unmodifiableMap(map); URI newUri=new UriBuilderImpl(uri).path("/{a}/{b}").buildFromEncodedMap(immutable); assertEquals("URI is not built correctly",new URI("http://zzz/foo%25/bar%25"),newUri); }

APIUtilityVerifier EqualityVerifier 
@Test public void testBuildFromEncodedMapComplex() throws Exception { Map maps=new HashMap(); maps.put("x","x%20yz"); maps.put("y","/path-absolute/%test1"); maps.put("z","fred@example.com"); maps.put("w","path-rootless/test2"); String expectedPath="path-rootless/test2/x%20yz//path-absolute/%25test1/fred@example.com/x%20yz"; URI uri=UriBuilder.fromPath("").path("{w}/{x}/{y}/{z}/{x}").buildFromEncodedMap(maps); String rawPath=uri.getRawPath(); assertEquals(expectedPath,rawPath); }

EqualityVerifier 
@Test public void testCloneWithoutLeadingSlash() throws Exception { URI uri=new URI("bar/foo"); URI newUri=new UriBuilderImpl(uri).clone().build(); assertEquals("URI is not built correctly","bar/foo",newUri.toString()); }

EqualityVerifier 
@Test public void testFromMethod(){ URI uri=UriBuilder.fromMethod(TestPath.class,"headSub").build(); assertEquals(uri.toString(),"/sub"); }

EqualityVerifier 
@Test public void testReplaceQueryStringWithTemplateValues(){ URI uri; uri=UriBuilder.fromUri("/index.jsp").replaceQuery("a={a}&b={b}").build("valueA","valueB"); assertEquals("/index.jsp?a=valueA&b=valueB",uri.toString()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testTck1(){ String value="test1#test2"; String expected="test1%23test2"; String path="{arg1}"; URI uri=UriBuilder.fromPath(path).build(value); assertEquals(expected,uri.toString()); }

APIUtilityVerifier EqualityVerifier 
@Test public void replaceMatrixParamWithEmptyPathTest() throws Exception { String name="name"; String expected="http://localhost:8080;name=x;name=y;name=y%20x;name=x%25y;name=%20"; URI uri=UriBuilder.fromPath("http://localhost:8080;name=x=;name=y?;name=x y;name=&").replaceMatrixParam(name,"x","y","y x","x%y","%20").build(); assertEquals(expected,uri.toString()); }

EqualityVerifier 
@Test public void testPathParamSpaceBuild3(){ String expected="http://localhost:8080/name%20space"; URI uri=UriBuilder.fromUri("http://localhost:8080").path("name space").build(); assertEquals(expected,uri.toString()); }

EqualityVerifier 
@Test public void testMatrixFinalPathSegment() throws Exception { URI uri=new URI("http://blah/foo;p1=v1/bar;p2=v2"); URI newUri=new UriBuilderImpl(uri).build(); assertEquals("URI is not built correctly",new URI("http://blah/foo;p1=v1/bar;p2=v2"),newUri); }

APIUtilityVerifier EqualityVerifier 
@Test public void testBuildFromMapValuesPct() throws Exception { URI uri=new URI("http://zzz"); Map map=new HashMap(); map.put("a","foo%25/bar%"); Map immutable=Collections.unmodifiableMap(map); URI newUri=new UriBuilderImpl(uri).path("/{a}").buildFromMap(immutable); assertEquals("URI is not built correctly",new URI("http://zzz/foo%2525%2Fbar%25"),newUri); }

EqualityVerifier 
@Test public void testMatrixWithNoValue() throws Exception { URI uri=new URI("http://bar/foo"); URI newUri=new UriBuilderImpl(uri).matrixParam("q").build(); assertEquals("URI is not built correctly","http://bar/foo;q",newUri.toString()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testAddPathMethod() throws Exception { Method meth=BookStore.class.getMethod("updateBook",Book.class); URI uri=new URI("http://foo/"); URI newUri=new UriBuilderImpl().uri(uri).path(meth).path("bar").build(); assertEquals("URI is not built correctly",new URI("http://foo/books/bar"),newUri); }

EqualityVerifier 
@Test public void testReplaceMatrixParamExisting() throws Exception { URI uri=new URI("http://foo/bar;p1=v1"); URI newUri=new UriBuilderImpl(uri).replaceMatrixParam("p1","nv1").build(); assertEquals("URI is not built correctly",new URI("http://foo/bar;p1=nv1"),newUri); }

EqualityVerifier 
@Test public void testReplaceMatrixParamValNull() throws Exception { URI uri=new URI("http://foo/bar;p1=v1;p2=v2;p1=v3?noise=bazzz"); URI newUri=new UriBuilderImpl(uri).replaceMatrixParam("p1",(Object)null).build(); assertEquals("URI is not built correctly",new URI("http://foo/bar;p2=v2?noise=bazzz"),newUri); }

EqualityVerifier 
@Test public void testReplaceQueryParamExistingMulti() throws Exception { URI uri=new URI("http://foo/bar?p1=v1&p2=v2"); URI newUri=new UriBuilderImpl(uri).replaceQueryParam("p1","nv1","nv2").build(); assertEquals("URI is not built correctly",new URI("http://foo/bar?p1=nv1&p1=nv2&p2=v2"),newUri); }

EqualityVerifier 
@Test public void testPathParamSpaceBuild2(){ String expected="http://localhost:8080/name/%2520"; URI uri=UriBuilder.fromUri("http://localhost:8080").path("name/{value}").build("%20"); assertEquals(expected,uri.toString()); }

EqualityVerifier 
@Test public void testPathParamSpaceBuildEncoded2(){ String expected="http://localhost:8080/name/%20"; URI uri=UriBuilder.fromUri("http://localhost:8080").path("name/{value}").buildFromEncoded("%20"); assertEquals(expected,uri.toString()); }

EqualityVerifier 
@Test public void testClonePctEncoded() throws Exception { URI uri=new URI("http://bar"); URI newUri=new UriBuilderImpl(uri).path("{a}").path("{b}").matrixParam("m","m1 ","m2+%20").queryParam("q","q1 ","q2+q3%20").clone().buildFromEncoded("a+ ","b%2B%20 "); assertEquals("URI is not built correctly","http://bar/a+%20/b%2B%20%20;m=m1%20;m=m2+%20?q=q1+&q=q2%2Bq3%20",newUri.toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testResolveTemplatesMapBooleanSlashEncoded() throws Exception { String expected="path-rootless%2Ftest2/x%25yz/%2Fpath-absolute%2F%2525test1/fred@example.com/x%25yz"; Map map=new HashMap(); map.put("x",new StringBuilder("x%yz")); map.put("y",new StringBuffer("/path-absolute/%25test1")); map.put("z",new Object(){ public String toString(){ return "fred@example.com"; } } ); map.put("w","path-rootless/test2"); UriBuilder builder=UriBuilder.fromPath("").path("{w}/{x}/{y}/{z}/{x}"); URI uri=builder.resolveTemplates(map,true).build(); assertEquals(expected,uri.getRawPath()); }

EqualityVerifier 
@Test public void testReplaceQuery() throws Exception { URI uri=new URI("http://foo/bar?p1=v1"); URI newUri=new UriBuilderImpl(uri).replaceQuery("p1=nv1").build(); assertEquals("URI is not built correctly",new URI("http://foo/bar?p1=nv1"),newUri); }

EqualityVerifier 
@Test public void testEncodedPathQueryFromExistingURI() throws Exception { URI uri=new URI("http://bar/foo+%20%2B?q=a+b%20%2B"); URI newUri=new UriBuilderImpl(uri).buildFromEncoded(); assertEquals("URI is not built correctly","http://bar/foo+%20%2B?q=a+b%20%2B",newUri.toString()); }

EqualityVerifier 
@Test public void testReplaceMatrix() throws Exception { URI uri=new URI("http://foo/bar;p1=v1;p2=v2"); URI newUri=new UriBuilderImpl(uri).replaceMatrix("p1=nv1").build(); assertEquals("URI is not built correctly",new URI("http://foo/bar;p1=nv1"),newUri); }

EqualityVerifier 
@Test public void testBuildValues() throws Exception { URI uri=new URI("http://zzz"); URI newUri=new UriBuilderImpl(uri).path("/{b}/{a}/{b}").build("foo","bar","baz"); assertEquals("URI is not built correctly",new URI("http://zzz/foo/bar/foo"),newUri); }

EqualityVerifier 
@Test public void testFromPathUriOnly(){ String expected="http://localhost:8080"; URI uri=UriBuilder.fromPath("http://localhost:8080").build(); assertEquals(expected,uri.toString()); }

EqualityVerifier 
@Test public void testEncodedAddedQuery() throws Exception { URI uri=new URI("http://bar"); URI newUri=new UriBuilderImpl(uri).queryParam("q","a+b%20%2B").buildFromEncoded(); assertEquals("URI is not built correctly","http://bar?q=a%2Bb%20%2B",newUri.toString()); }

EqualityVerifier 
@Test public void testEncodedPathWithAsteriscs() throws Exception { URI uri=new URI("http://bar/foo/"); URI newUri=new UriBuilderImpl(uri).path("*").buildFromEncoded(); assertEquals("URI is not built correctly","http://bar/foo/*",newUri.toString()); }

EqualityVerifier 
@Test public void testMatrixParamNewNameAndVal() throws Exception { URI uri=new URI("http://foo/bar;p1=v1"); URI newUri=new UriBuilderImpl(uri).matrixParam("p2","v2").build(); assertEquals("URI is not built correctly",new URI("http://foo/bar;p1=v1;p2=v2"),newUri); }

EqualityVerifier 
@Test public void testReplaceStringAndEncodeQueryParamFromBuild(){ String expected="http://localhost:8080?name1=x&name2=%20&name3=x+y&name4=23&name5=x%20y"; URI uri=UriBuilder.fromPath("http://localhost:8080").queryParam("name","x=","y?","x y","&").replaceQuery("name1=x&name2=%20&name3=x+y&name4=23&name5=x y").build(); assertEquals(expected,uri.toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testResolveTemplateFromMap2(){ String expected="path-rootless%2Ftest2/x%25yz/%2Fpath-absolute%2F%2525test1/fred@example.com/x%25yz"; Map map=new HashMap(); map.put("x",new StringBuilder("x%yz")); map.put("y",new StringBuffer("/path-absolute/%25test1")); map.put("z",new Object(){ public String toString(){ return "fred@example.com"; } } ); map.put("w","path-rootless/test2"); UriBuilder builder=UriBuilder.fromPath("").path("{w}/{x}/{y}/{z}/{x}"); URI uri=builder.resolveTemplates(map).build(); assertEquals(expected,uri.getRawPath()); }

EqualityVerifier 
@Test public void testMatrixParamSameNameAndVal() throws Exception { URI uri=new URI("http://foo/bar;p1=v1"); URI newUri=new UriBuilderImpl(uri).matrixParam("p1","v1").build(); assertEquals("URI is not built correctly",new URI("http://foo/bar;p1=v1;p1=v1"),newUri); }

EqualityVerifier 
@Test public void testPathParamSpaceBuild4(){ String expected="http://localhost:8080/name%20space"; URI uri=UriBuilder.fromUri("http://localhost:8080").path("name space").buildFromEncoded(); assertEquals(expected,uri.toString()); }

EqualityVerifier 
@Test public void testReplaceQueryNull() throws Exception { URI uri=new URI("http://foo/bar?p1=v1&p2=v2"); URI newUri=new UriBuilderImpl(uri).replaceQuery(null).build(); assertEquals("URI is not built correctly",new URI("http://foo/bar"),newUri); }

EqualityVerifier 
@Test public void testResolveTemplate(){ URI uri; uri=UriBuilder.fromPath("/{a}").resolveTemplate("a","1").build(); assertEquals("/1",uri.toString()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testBuildFromMapValues() throws Exception { URI uri=new URI("http://zzz"); Map map=new HashMap(); map.put("b","foo"); map.put("a","bar"); Map immutable=Collections.unmodifiableMap(map); URI newUri=new UriBuilderImpl(uri).path("/{b}/{a}/{b}").buildFromMap(immutable); assertEquals("URI is not built correctly",new URI("http://zzz/foo/bar/foo"),newUri); }

InternalCallVerifier EqualityVerifier 
@Test public void testAddPath() throws Exception { URI uri=new URI("http://foo/bar"); URI newUri=new UriBuilderImpl().uri(uri).path("baz").build(); assertEquals("URI is not built correctly",new URI("http://foo/bar/baz"),newUri); newUri=new UriBuilderImpl().uri(uri).path("baz").path("1").path("2").build(); assertEquals("URI is not built correctly",new URI("http://foo/bar/baz/1/2"),newUri); }

InternalCallVerifier EqualityVerifier 
@Test public void testAddPathClassMethod() throws Exception { URI uri=new URI("http://foo/"); URI newUri=new UriBuilderImpl().uri(uri).path(BookStore.class).path(BookStore.class,"updateBook").path("bar").build(); assertEquals("URI is not built correctly",new URI("http://foo/bookstore/books/bar"),newUri); }

EqualityVerifier 
@Test public void testBuildValuesPctEncoded() throws Exception { URI uri=new URI("http://zzz"); URI newUri=new UriBuilderImpl(uri).path("/{a}/{b}/{c}").buildFromEncoded("foo%25","bar%","baz%20"); assertEquals("URI is not built correctly",new URI("http://zzz/foo%25/bar%25/baz%20"),newUri); }

EqualityVerifier 
@Test public void testCloneWithLeadingSlash() throws Exception { URI uri=new URI("/bar/foo"); URI newUri=new UriBuilderImpl(uri).clone().build(); assertEquals("URI is not built correctly","/bar/foo",newUri.toString()); }

EqualityVerifier 
@Test public void testFromEncodedDuplicateVar3(){ String expected="http://localhost:8080/1/2/3/1"; URI uri=UriBuilder.fromPath("http://localhost:8080").path("/{a}/{b}/{c}/{a}").buildFromEncoded("1","2","3"); assertEquals(expected,uri.toString()); }

EqualityVerifier 
@Test public void testQueryParamWithTemplateValues(){ URI uri; uri=UriBuilder.fromPath("/index.jsp").queryParam("a","{a}").queryParam("b","{b}").build("valueA","valueB"); assertEquals("/index.jsp?a=valueA&b=valueB",uri.toString()); }

EqualityVerifier 
@Test public void testBuildWithNonEncodedSubstitutionValue(){ URI uri; uri=UriBuilder.fromPath("/{a}").build("{}"); assertEquals("/%7B%7D",uri.toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testUriTemplate2() throws Exception { UriBuilder builder=UriBuilder.fromUri("http://localhost/{a}/{b}"); URI uri=builder.build("1","2"); assertEquals("http://localhost/1/2",uri.toString()); }

EqualityVerifier 
@Test public void testClonePctEncodedFromUri() throws Exception { URI uri=new URI("http://bar/foo%20"); URI newUri=new UriBuilderImpl(uri).clone().buildFromEncoded(); assertEquals("URI is not built correctly","http://bar/foo%20",newUri.toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testResolveTemplateFromEncodedMap(){ String expected="path-rootless%2Ftest2/x%25yz/%2Fpath-absolute%2F%2525test1/fred@example.com/x%25yz"; Map map=new HashMap(); map.put("v",new StringBuilder("path-rootless%2Ftest2")); map.put("w",new StringBuilder("x%yz")); map.put("x",new Object(){ public String toString(){ return "%2Fpath-absolute%2F%2525test1"; } } ); map.put("y","fred@example.com"); UriBuilder builder=UriBuilder.fromPath("").path("{v}/{w}/{x}/{y}/{w}"); builder=builder.resolveTemplatesFromEncoded(map); URI uri=builder.build(); assertEquals(expected,uri.getRawPath()); }

EqualityVerifier 
@Test public void testReplaceQueryEmpty() throws Exception { URI uri=new URI("http://foo/bar?p1=v1&p2=v2"); URI newUri=new UriBuilderImpl(uri).replaceQuery("").build(); assertEquals("URI is not built correctly",new URI("http://foo/bar"),newUri); }

APIUtilityVerifier EqualityVerifier 
@Test public void testSegments4(){ String path1="ab"; String[] path2={"a1","{xy}","3b "}; String expected="ab/a1/x/y/3b%20"; URI uri=UriBuilder.fromPath(path1).segment(path2).build(new Object[]{"x/y"},false); assertEquals(uri.toString(),expected); }

EqualityVerifier 
@Test public void testFromEncodedDuplicateVar2(){ String expected="http://localhost:8080/xy/%20/%25/xy"; URI uri=UriBuilder.fromPath("http://localhost:8080").path("/{x}/{y}/{z}/{x}").buildFromEncoded("xy"," ","%"); assertEquals(expected,uri.toString()); }

EqualityVerifier 
@Test public void testQueryParamMultiVal() throws Exception { URI uri=new URI("http://foo/bar?p1=v1"); URI newUri=new UriBuilderImpl(uri).queryParam("p1","v2","v3").build(); assertEquals("URI is not built correctly",new URI("http://foo/bar?p1=v1&p1=v2&p1=v3"),newUri); }

APIUtilityVerifier EqualityVerifier 
@Test public void replaceMatrixWithEmptyPathTest() throws Exception { String expected="http://localhost:8080;name=x;name=y;name=y%20x;name=x%25y;name=%20"; String value="name=x;name=y;name=y x;name=x%y;name= "; URI uri=UriBuilder.fromPath("http://localhost:8080;name=x=;name=y?;name=x y;name=&").replaceMatrix(value).build(); assertEquals(expected,uri.toString()); }

EqualityVerifier 
@Test public void testBuildValuesPct() throws Exception { URI uri=new URI("http://zzz"); URI newUri=new UriBuilderImpl(uri).path("/{a}").build("foo%25/bar%"); assertEquals("URI is not built correctly",new URI("http://zzz/foo%2525%2Fbar%25"),newUri); }

EqualityVerifier 
@Test public void testReplaceQueryParamExisting() throws Exception { URI uri=new URI("http://foo/bar?p1=v1"); URI newUri=new UriBuilderImpl(uri).replaceQueryParam("p1","nv1").build(); assertEquals("URI is not built correctly",new URI("http://foo/bar?p1=nv1"),newUri); }

EqualityVerifier 
@Test public void testPathParamSpaceBuild(){ String expected="http://localhost:8080/name/%20"; URI uri=UriBuilder.fromUri("http://localhost:8080").path("name/%20").build(); assertEquals(expected,uri.toString()); }

EqualityVerifier 
@Test public void testReplaceMatrixParamValEmpty() throws Exception { URI uri=new URI("http://foo/bar;p1=v1;p2=v2;p1=v3?noise=bazzz"); URI newUri=new UriBuilderImpl(uri).replaceMatrixParam("p1").build(); assertEquals("URI is not built correctly",new URI("http://foo/bar;p2=v2?noise=bazzz"),newUri); }

InternalCallVerifier EqualityVerifier 
@Test public void testUri() throws Exception { URI uri=new URI("http://foo/bar/baz?query=1#fragment"); URI newUri=new UriBuilderImpl().uri(uri).build(); assertEquals("URI is not built correctly",uri,newUri); }

APIUtilityVerifier EqualityVerifier 
@Test public void testPathEncodedSlashNot(){ String path1="ab"; String path2="{xy}"; String expected="ab/x/y"; URI uri=UriBuilder.fromPath(path1).path(path2).build(new Object[]{"x/y"},false); assertEquals(uri.toString(),expected); }

EqualityVerifier 
@Test public void testOpaqueSchemeSpecificPart() throws Exception { URI expectedUri=new URI("mailto:javanet@java.net.com"); URI newUri=new UriBuilderImpl().scheme("mailto").schemeSpecificPart("javanet@java.net.com").build(); assertEquals("URI is not built correctly",expectedUri,newUri); }

EqualityVerifier 
@Test public void testReplaceQuery3(){ String expected="http://localhost:8080?name1=xyz"; URI uri=UriBuilder.fromPath("http://localhost:8080").queryParam("name","x=","y?","x y","&").replaceQuery("name1=xyz").build(); assertEquals(expected,uri.toString()); }

EqualityVerifier 
@Test public void testMatrixParamMultiSameNameNewVals() throws Exception { URI uri=new URI("http://foo/bar;p1=v1"); URI newUri=new UriBuilderImpl(uri).matrixParam("p1","v2","v3").build(); assertEquals("URI is not built correctly",new URI("http://foo/bar;p1=v1;p1=v2;p1=v3"),newUri); }

APIUtilityVerifier EqualityVerifier 
@Test public void testBuildFromEncodedMapComplex2() throws Exception { Map maps=new HashMap(); maps.put("x","x%yz"); maps.put("y","/path-absolute/test1"); maps.put("z","fred@example.com"); maps.put("w","path-rootless/test2"); maps.put("u","extra"); String expectedPath="path-rootless/test2/x%25yz//path-absolute/test1/fred@example.com/x%25yz"; URI uri=UriBuilder.fromPath("").path("{w}/{x}/{y}/{z}/{x}").buildFromEncodedMap(maps); String rawPath=uri.getRawPath(); assertEquals(expectedPath,rawPath); }

EqualityVerifier 
@Test public void testFromEncodedDuplicateVar(){ String expected="http://localhost:8080/a/%25/=/%25G0/%25/="; URI uri=UriBuilder.fromPath("http://localhost:8080").path("/{v}/{w}/{x}/{y}/{z}/{x}").buildFromEncoded("a","%25","=","%G0","%","23"); assertEquals(expected,uri.toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testAddPathSlashes() throws Exception { URI uri=new URI("http://foo/"); URI newUri=new UriBuilderImpl().uri(uri).path("/bar").path("baz/").path("/blah/").build(); assertEquals("URI is not built correctly",new URI("http://foo/bar/baz/blah/"),newUri); }

InternalCallVerifier EqualityVerifier 
@Test public void testAddPathClass() throws Exception { URI uri=new URI("http://foo/"); URI newUri=new UriBuilderImpl().uri(uri).path(BookStore.class).path("/").build(); assertEquals("URI is not built correctly",new URI("http://foo/bookstore/"),newUri); }

APIUtilityVerifier EqualityVerifier 
@Test public void testPathEncodedSlash(){ String path1="ab"; String path2="{xy}"; String expected="ab/x%2Fy"; URI uri=UriBuilder.fromPath(path1).path(path2).build(new Object[]{"x/y"},true); assertEquals(uri.toString(),expected); }

EqualityVerifier 
@Test public void testReplaceMatrix2() throws Exception { URI uri=new URI("http://foo/bar/"); URI newUri=new UriBuilderImpl(uri).replaceMatrix("p1=nv1").build(); assertEquals("URI is not built correctly",new URI("http://foo/bar/;p1=nv1"),newUri); }

EqualityVerifier 
@Test public void testSchemeSpecificPart() throws Exception { URI uri=new URI("http://bar"); URI newUri=new UriBuilderImpl(uri).scheme("https").schemeSpecificPart("//localhost:8080/foo/bar").build(); assertEquals("URI is not built correctly","https://localhost:8080/foo/bar",newUri.toString()); }

EqualityVerifier 
@Test public void testReplaceQuery2() throws Exception { URI uri=new URI("http://foo/bar"); URI newUri=new UriBuilderImpl(uri).replaceQuery("p1=nv1").build(); assertEquals("URI is not built correctly",new URI("http://foo/bar?p1=nv1"),newUri); }

EqualityVerifier 
@Test public void testBuildValueWithBrackets() throws Exception { URI uri=new URI("http://zzz"); URI newUri=new UriBuilderImpl(uri).path("/{a}").build("{foo}"); assertEquals("URI is not built correctly",new URI("http://zzz/%7Bfoo%7D"),newUri); }

EqualityVerifier 
@Test public void testPathWithAsteriscs() throws Exception { URI uri=new URI("http://bar/foo/"); URI newUri=new UriBuilderImpl(uri).path("*").build(); assertEquals("URI is not built correctly","http://bar/foo/*",newUri.toString()); }

EqualityVerifier 
@Test public void testMatrixWithSlash() throws Exception { URI uri=new URI("http://bar/foo"); URI newUri=new UriBuilderImpl(uri).matrixParam("q","1/2").build(); assertEquals("URI is not built correctly","http://bar/foo;q=1%2F2",newUri.toString()); }

EqualityVerifier 
@Test public void testResolveTemplate2(){ URI uri; uri=UriBuilder.fromPath("/{a}/{b}").resolveTemplate("a","1").build("2"); assertEquals("/1/2",uri.toString()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testBuildWithLeadingSlash() throws Exception { URI uri=new URI("/bar/foo"); URI newUri=UriBuilder.fromUri(uri).build(); assertEquals("URI is not built correctly","/bar/foo",newUri.toString()); }

EqualityVerifier 
@Test public void testQueryWithNoValue() throws Exception { URI uri=new URI("http://bar"); URI newUri=new UriBuilderImpl(uri).queryParam("q").build(); assertEquals("URI is not built correctly","http://bar?q",newUri.toString()); }

EqualityVerifier 
@Test public void testReplaceQueryParamValEmpty() throws Exception { URI uri=new URI("http://foo/bar?p1=v1&p2=v2&p1=v3"); URI newUri=new UriBuilderImpl(uri).replaceQueryParam("p1").build(); assertEquals("URI is not built correctly",new URI("http://foo/bar?p2=v2"),newUri); }

EqualityVerifier 
@Test public void testReplaceMatrixEmpty() throws Exception { URI uri=new URI("http://foo/bar;p1=v1;p2=v2"); URI newUri=new UriBuilderImpl(uri).replaceMatrix("").build(); assertEquals("URI is not built correctly",new URI("http://foo/bar"),newUri); }

EqualityVerifier 
@Test public void testQueryParamSameNameAndVal() throws Exception { URI uri=new URI("http://foo/bar?p1=v1"); URI newUri=new UriBuilderImpl(uri).queryParam("p1","v1").build(); assertEquals("URI is not built correctly",new URI("http://foo/bar?p1=v1&p1=v1"),newUri); }

EqualityVerifier 
@Test public void testCtorAndBuild() throws Exception { URI uri=new URI("http://foo/bar/baz?query=1#fragment"); URI newUri=new UriBuilderImpl(uri).build(); assertEquals("URI is not built correctly",uri,newUri); }

APIUtilityVerifier EqualityVerifier 
@Test public void testPathAndQueryParamUsingMapWithTemplateValues(){ Map values=new HashMap(); values.put("a","valueA"); values.put("b","valueB"); values.put("ind","1"); URI uri; uri=UriBuilder.fromPath("/index{ind}.jsp").queryParam("a","{a}").queryParam("b","{b}").buildFromMap(values); assertEquals("/index1.jsp?a=valueA&b=valueB",uri.toString()); }

EqualityVerifier 
@Test public void testEncodingQueryParamFromBuild() throws Exception { String expectedValue="http://localhost:8080?name=x%3D&name=y?&name=x+y&name=%26"; URI uri=UriBuilder.fromPath("http://localhost:8080").queryParam("name","x=","y?","x y","&").build(); assertEquals(expectedValue,uri.toString()); }

EqualityVerifier 
@Test public void testAddPathWithMatrix() throws Exception { URI uri=new URI("http://blah/foo/bar;p1=v1"); URI newUri=new UriBuilderImpl(uri).path("baz;p2=v2").build(); assertEquals("URI is not built correctly",new URI("http://blah/foo/bar;p1=v1/baz;p2=v2"),newUri); }

InternalCallVerifier EqualityVerifier 
@Test public void testResolveTemplatesMapBooleanSlashNotEncoded() throws Exception { String expected="path-rootless/test2/x%25yz//path-absolute/test1/fred@example.com/x%25yz"; Map map=new HashMap(); map.put("x",new StringBuilder("x%yz")); map.put("y",new StringBuffer("/path-absolute/test1")); map.put("z",new Object(){ public String toString(){ return "fred@example.com"; } } ); map.put("w","path-rootless/test2"); UriBuilder builder=UriBuilder.fromPath("").path("{w}/{x}/{y}/{z}/{x}"); URI uri=builder.resolveTemplates(map,false).build(); assertEquals(expected,uri.getRawPath()); }

EqualityVerifier 
@Test public void testBuildWithNonEncodedSubstitutionValue2(){ URI uri; uri=UriBuilder.fromPath("/{a}").buildFromEncoded("{}"); assertEquals("/%7B%7D",uri.toString()); }

EqualityVerifier 
@Test public void testTrailingSlash() throws Exception { URI uri=new URI("http://bar/"); URI newUri=new UriBuilderImpl(uri).build(); assertEquals("URI is not built correctly","http://bar/",newUri.toString()); }

EqualityVerifier 
@Test public void testReplacePathHttpString() throws Exception { URI uri=new URI("http://foo/bar/baz;m1=m1value"); URI newUri=new UriBuilderImpl(uri).replacePath("httppnewpath").build(); assertEquals("URI is not built correctly","http://foo/httppnewpath",newUri.toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testAddPathSlashes3() throws Exception { URI uri=new URI("http://foo/"); URI newUri=new UriBuilderImpl().uri(uri).path("/bar/").path("").path("baz").build(); assertEquals("URI is not built correctly",new URI("http://foo/bar/baz"),newUri); }

EqualityVerifier 
@Test public void testPctEncodedMatrixParam() throws Exception { URI uri=new URI("http://foo/bar"); URI newUri=new UriBuilderImpl(uri).matrixParam("p1","v1%20").buildFromEncoded(); assertEquals("URI is not built correctly",new URI("http://foo/bar;p1=v1%20"),newUri); }

EqualityVerifier 
@Test public void testPathTrailingSlash2() throws Exception { URI uri=new URI("http://bar"); URI newUri=new UriBuilderImpl(uri).path("/").path("/").build(); assertEquals("URI is not built correctly","http://bar/",newUri.toString()); }

EqualityVerifier 
@Test public void testPathAndQueryParamWithTemplateValues(){ URI uri; uri=UriBuilder.fromPath("/index{ind}.jsp").queryParam("a","{a}").queryParam("b","{b}").build("1","valueA","valueB"); assertEquals("/index1.jsp?a=valueA&b=valueB",uri.toString()); }

EqualityVerifier 
@Test public void testQueryParamSameNameDiffVal() throws Exception { URI uri=new URI("http://foo/bar?p1=v1"); URI newUri=new UriBuilderImpl(uri).queryParam("p1","v2").build(); assertEquals("URI is not built correctly",new URI("http://foo/bar?p1=v1&p1=v2"),newUri); }

InternalCallVerifier EqualityVerifier 
@Test public void testToTemplateAndResolved(){ Map templs=new HashMap(); templs.put("a","1"); templs.put("b","2"); String template=((UriBuilderImpl)UriBuilder.fromPath("/{a}/{b}").queryParam("c","{c}")).resolveTemplates(templs).toTemplate(); assertEquals("/1/2?c={c}",template); }

InternalCallVerifier EqualityVerifier 
@Test public void testBuildWithNonEncodedSubstitutionValue3(){ UriBuilder ub=UriBuilder.fromPath("/"); URI uri=ub.path("{a}").buildFromEncoded("%"); assertEquals("/%25",uri.toString()); uri=ub.path("{token}").buildFromEncoded("%","{}"); assertEquals("/%25/%7B%7D",uri.toString()); }

EqualityVerifier 
@Test public void testMatrixParamSameNameDiffVal() throws Exception { URI uri=new URI("http://foo/bar;p1=v1"); URI newUri=new UriBuilderImpl(uri).matrixParam("p1","v2").build(); assertEquals("URI is not built correctly",new URI("http://foo/bar;p1=v1;p1=v2"),newUri); }

EqualityVerifier 
@Test public void testResolveTemplateFromMap(){ URI uri; uri=UriBuilder.fromPath("/{a}/{b}").resolveTemplate("a","1").buildFromMap(Collections.singletonMap("b","2")); assertEquals("/1/2",uri.toString()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testBuildFromMapValueWithBrackets() throws Exception { URI uri=new URI("http://zzz"); Map map=new HashMap(); map.put("a","{foo}"); Map immutable=Collections.unmodifiableMap(map); URI newUri=new UriBuilderImpl(uri).path("/{a}").buildFromMap(immutable); assertEquals("URI is not built correctly",new URI("http://zzz/%7Bfoo%7D"),newUri); }

APIUtilityVerifier EqualityVerifier 
@Test public void testSegments2(){ String path1=""; String[] path2={"a1","/","3b "}; String expected="a1/%2F/3b%20"; URI uri=UriBuilder.fromPath(path1).segment(path2).build(); assertEquals(expected,uri.toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testAddPathSlashes2() throws Exception { URI uri=new URI("http://foo/"); URI newUri=new UriBuilderImpl().uri(uri).path("/bar///baz").path("blah//").build(); assertEquals("URI is not built correctly",new URI("http://foo/bar/baz/blah/"),newUri); }

InternalCallVerifier EqualityVerifier 
@Test public void testBuildWithNonEncodedSubstitutionValue4(){ UriBuilder ub=UriBuilder.fromPath("/"); URI uri=ub.path("{a}").build("%"); assertEquals("/%25",uri.toString()); uri=ub.path("{token}").build("%","{}"); assertEquals("/%25/%7B%7D",uri.toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testUriTemplate() throws Exception { UriBuilder builder=UriBuilder.fromUri("http://localhost:8080/{a}/{b}"); URI uri=builder.build("1","2"); assertEquals("http://localhost:8080/1/2",uri.toString()); }

EqualityVerifier 
@Test public void testPathWithTwoAsteriscs() throws Exception { URI uri=new URI("http://bar/foo/"); URI newUri=new UriBuilderImpl(uri).path("**").build(); assertEquals("URI is not built correctly","http://bar/foo/**",newUri.toString()); }

IterativeVerifier EqualityVerifier 
@Test public void testNonHttpSchemes(){ String[] uris={"ftp://ftp.is.co.za/rfc/rfc1808.txt","mailto:java-net@java.sun.com","news:comp.lang.java","urn:isbn:096139212y","ldap://[2001:db8::7]/c=GB?objectClass?one","telnet://194.1.2.17:81/","tel:+1-816-555-1212","foo://bar.com:8042/there/here?name=baz#brr"}; int expectedCount=0; for (int i=0; i < uris.length; i++) { URI uri=UriBuilder.fromUri(uris[i]).build(); assertEquals("Strange",uri.toString(),uris[i]); expectedCount++; } assertEquals(8,expectedCount); }

APIUtilityVerifier EqualityVerifier 
@Test public void testQueryParamUsingMapWithTemplateValues(){ Map values=new HashMap(); values.put("a","valueA"); values.put("b","valueB"); URI uri; uri=UriBuilder.fromPath("/index.jsp").queryParam("a","{a}").queryParam("b","{b}").buildFromMap(values); assertEquals("/index.jsp?a=valueA&b=valueB",uri.toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testBuildWithNonEncodedSubstitutionValue5(){ UriBuilder ub=UriBuilder.fromUri("/%25"); URI uri=ub.build(); assertEquals("/%25",uri.toString()); uri=ub.replacePath("/%/{token}").build("{}"); assertEquals("/%25/%7B%7D",uri.toString()); }

EqualityVerifier 
@Test public void testQueryParamSpaceBuild2(){ String expected="http://localhost:8080?name=%2520"; URI uri=UriBuilder.fromUri("http://localhost:8080").queryParam("name","{value}").build("%20"); assertEquals(expected,uri.toString()); }

EqualityVerifier 
@Test public void testResetPort(){ URI uri=UriBuilder.fromUri("http://localhost:8080/some/path").port(-1).build(); assertEquals("http://localhost/some/path",uri.toString()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testSegments3(){ String path1="ab"; String[] path2={"a1","{xy}","3b "}; String expected="ab/a1/x%2Fy/3b%20"; URI uri=UriBuilder.fromPath(path1).segment(path2).build("x/y"); assertEquals(uri.toString(),expected); }

EqualityVerifier 
@Test public void testMatrixNonFinalPathSegment() throws Exception { URI uri=new URI("http://blah/foo;p1=v1/bar"); URI newUri=new UriBuilderImpl(uri).build(); assertEquals("URI is not built correctly",new URI("http://blah/foo;p1=v1/bar"),newUri); }

APIUtilityVerifier EqualityVerifier 
@Test public void testFragment(){ String expected="test#abc"; String path="test"; URI uri=UriBuilder.fromPath(path).fragment("abc").build(); assertEquals(expected,uri.toString()); }

Class: org.apache.cxf.jaxrs.impl.UriInfoImplTest

InternalCallVerifier EqualityVerifier 
@Test public void testGetCaseinsensitiveQueryParameters(){ UriInfoImpl u=new UriInfoImpl(mockMessage("http://localhost:8080/baz","/bar"),null); assertEquals("unexpected queries",0,u.getQueryParameters().size()); Message m=mockMessage("http://localhost:8080/baz","/bar","N=1%202&n=3&b=2&a%2Eb=ab"); m.put("org.apache.cxf.http.case_insensitive_queries","true"); u=new UriInfoImpl(m,null); MultivaluedMap qps=u.getQueryParameters(); assertEquals("Number of queiries is wrong",3,qps.size()); assertEquals("Wrong query value",qps.get("n").get(0),"1 2"); assertEquals("Wrong query value",qps.get("n").get(1),"3"); assertEquals("Wrong query value",qps.get("b").get(0),"2"); assertEquals("Wrong query value",qps.get("a.b").get(0),"ab"); }

EqualityVerifier 
@Test public void testGetAbsolutePathWithEncodedChars(){ UriInfoImpl u=new UriInfoImpl(mockMessage("http://localhost:8080/baz%20foo","/bar"),null); assertEquals("Wrong absolute path","http://localhost:8080/baz%20foo/bar",u.getAbsolutePath().toString()); u=new UriInfoImpl(mockMessage("http://localhost:8080/baz/%20foo","/bar%20foo"),null); assertEquals("Wrong absolute path","http://localhost:8080/baz/%20foo/bar%20foo",u.getAbsolutePath().toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testRelativizeAlreadyRelative() throws Exception { Message mockMessage=mockMessage("http://localhost:8080/app/root/","/soup/"); UriInfoImpl u=new UriInfoImpl(mockMessage,null); assertEquals("http://localhost:8080/app/root/soup/",u.getRequestUri().toString()); URI x=URI.create("x/"); assertEquals("http://localhost:8080/app/root/x/",u.resolve(x).toString()); assertEquals("../x/",u.relativize(x).toString()); }

EqualityVerifier 
@Test public void testGetRequestURIWithEncodedChars(){ UriInfo u=new UriInfoImpl(mockMessage("http://localhost:8080/baz/bar","/foo/%20bar","n=1%202"),null); assertEquals("Wrong request uri","http://localhost:8080/baz/bar/foo/%20bar?n=1%202",u.getRequestUri().toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testRelativizeChild() throws Exception { Message mockMessage=mockMessage("http://example.com/app/root/","/a/b/c/"); UriInfoImpl u=new UriInfoImpl(mockMessage,null); assertEquals("http://example.com/app/root/a/b/c/",u.getRequestUri().toString()); URI absolute=URI.create("http://example.com/app/root/a/b/c/d/e"); assertEquals("d/e",u.relativize(absolute).toString()); URI relativeToBase=URI.create("a/b/c/d/e"); assertEquals("d/e",u.relativize(relativeToBase).toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testRelativizeGrandParent() throws Exception { Message mockMessage=mockMessage("http://example.com/app/root/","/a/b/c/"); UriInfoImpl u=new UriInfoImpl(mockMessage,null); assertEquals("http://example.com/app/root/a/b/c/",u.getRequestUri().toString()); URI absolute=URI.create("http://example.com/app/root/a/"); assertEquals("../../",u.relativize(absolute).toString()); URI relativeToBase=URI.create("a/"); assertEquals("../../",u.relativize(relativeToBase).toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetQueryParameters(){ UriInfoImpl u=new UriInfoImpl(mockMessage("http://localhost:8080/baz","/bar"),null); assertEquals("unexpected queries",0,u.getQueryParameters().size()); u=new UriInfoImpl(mockMessage("http://localhost:8080/baz","/bar","n=1%202"),null); MultivaluedMap qps=u.getQueryParameters(false); assertEquals("Number of queries is wrong",1,qps.size()); assertEquals("Wrong query value",qps.getFirst("n"),"1%202"); u=new UriInfoImpl(mockMessage("http://localhost:8080/baz","/bar","N=0&n=1%202&n=3&b=2&a%2Eb=ab"),null); qps=u.getQueryParameters(); assertEquals("Number of queiries is wrong",4,qps.size()); assertEquals("Wrong query value",qps.get("N").get(0),"0"); assertEquals("Wrong query value",qps.get("n").get(0),"1 2"); assertEquals("Wrong query value",qps.get("n").get(1),"3"); assertEquals("Wrong query value",qps.get("b").get(0),"2"); assertEquals("Wrong query value",qps.get("a.b").get(0),"ab"); }

EqualityVerifier 
@Test public void testGetAbsolutePath(){ UriInfoImpl u=new UriInfoImpl(mockMessage("http://localhost:8080/baz","/bar"),null); assertEquals("Wrong absolute path","http://localhost:8080/baz/bar",u.getAbsolutePath().toString()); u=new UriInfoImpl(mockMessage("http://localhost:8080/baz/","/bar"),null); assertEquals("Wrong absolute path","http://localhost:8080/baz/bar",u.getAbsolutePath().toString()); u=new UriInfoImpl(mockMessage("http://localhost:8080/baz","bar"),null); assertEquals("Wrong absolute path","http://localhost:8080/baz/bar",u.getAbsolutePath().toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testRelativizeOutsideBase() throws Exception { Message mockMessage=mockMessage("http://example.com/app/root/","/a/b/c/"); UriInfoImpl u=new UriInfoImpl(mockMessage,null); assertEquals("http://example.com/app/root/a/b/c/",u.getRequestUri().toString()); URI absolute=URI.create("http://example.com/otherapp/fred.txt"); assertEquals("../../../../../otherapp/fred.txt",u.relativize(absolute).toString()); URI relativeToBase=URI.create("../../otherapp/fred.txt"); assertEquals("../../../../../otherapp/fred.txt",u.relativize(relativeToBase).toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testResolveNormalizeComplex() throws Exception { UriInfoImpl u=new UriInfoImpl(mockMessage("http://localhost:8080/baz/1/2/3/",null),null); assertEquals("Wrong base path","http://localhost:8080/baz/1/2/3/",u.getBaseUri().toString()); URI resolved=u.resolve(new URI("../../a")); assertEquals("http://localhost:8080/baz/1/a",resolved.toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testRelativizeSibling() throws Exception { Message mockMessage=mockMessage("http://example.com/app/root/","/a/b/c.html"); UriInfoImpl u=new UriInfoImpl(mockMessage,null); assertEquals("http://example.com/app/root/a/b/c.html",u.getRequestUri().toString()); URI absolute=URI.create("http://example.com/app/root/a/b/c.pdf"); assertEquals("c.pdf",u.relativize(absolute).toString()); URI relativeToBase=URI.create("a/b/c.pdf"); assertEquals("c.pdf",u.relativize(relativeToBase).toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testRelativizeNoCommonPrefix() throws Exception { Message mockMessage=mockMessage("http://localhost:8080/app/root/","/soup"); UriInfoImpl u=new UriInfoImpl(mockMessage,null); assertEquals("http://localhost:8080/app/root/soup",u.getRequestUri().toString()); URI otherHost=URI.create("http://localhost:8081/app/root/x"); assertEquals(otherHost,u.resolve(otherHost)); assertEquals(otherHost,u.relativize(otherHost)); }

EqualityVerifier 
@Test public void testGetRequestURI(){ UriInfo u=new UriInfoImpl(mockMessage("http://localhost:8080/baz/bar","/foo","n=1%202"),null); assertEquals("Wrong request uri","http://localhost:8080/baz/bar/foo?n=1%202",u.getRequestUri().toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testResolveNormalizeSimple(){ UriInfoImpl u=new UriInfoImpl(mockMessage("http://localhost:8080/baz",null),null); assertEquals("Wrong base path","http://localhost:8080/baz",u.getBaseUri().toString()); URI resolved=u.resolve(URI.create("./a")); assertEquals("http://localhost:8080/a",resolved.toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testResolve(){ UriInfoImpl u=new UriInfoImpl(mockMessage("http://localhost:8080/baz/",null),null); assertEquals("Wrong base path","http://localhost:8080/baz/",u.getBaseUri().toString()); URI resolved=u.resolve(URI.create("a")); assertEquals("http://localhost:8080/baz/a",resolved.toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetTemplateParameters(){ MultivaluedMap values=new MetadataMap(); new URITemplate("/bar").match("/baz",values); UriInfoImpl u=new UriInfoImpl(mockMessage("http://localhost:8080/baz","/bar"),values); assertEquals("unexpected templates",0,u.getPathParameters().size()); values.clear(); new URITemplate("/{id}").match("/bar%201",values); u=new UriInfoImpl(mockMessage("http://localhost:8080/baz","/bar%201"),values); MultivaluedMap tps=u.getPathParameters(false); assertEquals("Number of templates is wrong",1,tps.size()); assertEquals("Wrong template value",tps.getFirst("id"),"bar%201"); values.clear(); new URITemplate("/{id}/{baz}").match("/1%202/bar",values); u=new UriInfoImpl(mockMessage("http://localhost:8080/baz","/1%202/bar"),values); tps=u.getPathParameters(); assertEquals("Number of templates is wrong",2,tps.size()); assertEquals("Wrong template value",tps.getFirst("id"),"1 2"); assertEquals("Wrong template value",tps.getFirst("baz"),"bar"); values.clear(); new URITemplate("/bar").match("/bar",values); u=new UriInfoImpl(mockMessage("http://localhost:8080/baz","/bar"),values); assertEquals("unexpected templates",0,u.getPathParameters().size()); }

EqualityVerifier 
@Test public void testGetPath(){ UriInfoImpl u=new UriInfoImpl(mockMessage("http://localhost:8080/bar/baz","/baz"),null); assertEquals("Wrong path","baz",u.getPath()); u=new UriInfoImpl(mockMessage("http://localhost:8080/bar/baz","/bar/baz"),null); assertEquals("Wrong path","/",u.getPath()); u=new UriInfoImpl(mockMessage("http://localhost:8080/bar/baz/","/bar/baz/"),null); assertEquals("Wrong path","/",u.getPath()); u=new UriInfoImpl(mockMessage("http://localhost:8080/baz","/baz/bar%201"),null); assertEquals("Wrong path","bar 1",u.getPath()); u=new UriInfoImpl(mockMessage("http://localhost:8080/baz","/baz/bar%201"),null); assertEquals("Wrong path","bar%201",u.getPath(false)); }

InternalCallVerifier EqualityVerifier 
@Test public void testRelativizeCousin() throws Exception { Message mockMessage=mockMessage("http://example.com/app/root/","/a/b/c/"); UriInfoImpl u=new UriInfoImpl(mockMessage,null); assertEquals("http://example.com/app/root/a/b/c/",u.getRequestUri().toString()); URI absolute=URI.create("http://example.com/app/root/a/b2/c2/"); assertEquals("../../b2/c2/",u.relativize(absolute).toString()); URI relativeToBase=URI.create("a/b2/c2/"); assertEquals("../../b2/c2/",u.relativize(relativeToBase).toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetEncodedPathSegments(){ UriInfoImpl u=new UriInfoImpl(mockMessage("http://localhost:8080","/bar/foo/x%2Fb"),null); List segments=u.getPathSegments(false); assertEquals(3,segments.size()); assertEquals("bar",segments.get(0).toString()); assertEquals("foo",segments.get(1).toString()); assertEquals("x%2Fb",segments.get(2).toString()); }

EqualityVerifier 
@Test public void testGetBaseUri(){ UriInfoImpl u=new UriInfoImpl(mockMessage("http://localhost:8080/baz",null),null); assertEquals("Wrong base path","http://localhost:8080/baz",u.getBaseUri().toString()); u=new UriInfoImpl(mockMessage("http://localhost:8080/baz/",null),null); assertEquals("Wrong base path","http://localhost:8080/baz/",u.getBaseUri().toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testRelativize(){ UriInfoImpl u=new UriInfoImpl(mockMessage("http://localhost:8080/app/root","/a/b/c"),null); assertEquals("Wrong Request Uri","http://localhost:8080/app/root/a/b/c",u.getRequestUri().toString()); URI relativized=u.relativize(URI.create("http://localhost:8080/app/root/a/d/e")); assertEquals("../d/e",relativized.toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetPathSegments(){ UriInfoImpl u=new UriInfoImpl(mockMessage("http://localhost:8080","/bar/foo/x%2Fb"),null); List segments=u.getPathSegments(); assertEquals(3,segments.size()); assertEquals("bar",segments.get(0).toString()); assertEquals("foo",segments.get(1).toString()); assertEquals("x/b",segments.get(2).toString()); }

Class: org.apache.cxf.jaxrs.impl.VariantListBuilderImplTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testBuildEnc(){ VariantListBuilderImpl vb=new VariantListBuilderImpl(); List variants=vb.encodings("zip","identity").add().build(); assertEquals("2 variants need to be created",2,variants.size()); assertTrue(verifyVariant(variants,new Variant(null,(Locale)null,"zip"))); assertTrue(verifyVariant(variants,new Variant(null,(Locale)null,"identity"))); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testBuildType(){ VariantListBuilderImpl vb=new VariantListBuilderImpl(); List variants=vb.mediaTypes(new MediaType("*","*"),new MediaType("text","xml")).add().build(); assertEquals("2 variants need to be created",2,variants.size()); assertTrue(verifyVariant(variants,new Variant(new MediaType("*","*"),(Locale)null,null))); assertTrue(verifyVariant(variants,new Variant(new MediaType("text","xml"),(Locale)null,null))); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testBuildTypeAndLang(){ VariantListBuilderImpl vb=new VariantListBuilderImpl(); MediaType mt1=new MediaType("*","*"); MediaType mt2=new MediaType("text","xml"); List variants=vb.mediaTypes(mt1,mt2).languages(new Locale("en"),new Locale("fr")).add().build(); assertEquals("8 variants need to be created",4,variants.size()); assertTrue(verifyVariant(variants,new Variant(mt1,new Locale("en"),null))); assertTrue(verifyVariant(variants,new Variant(mt1,new Locale("fr"),null))); assertTrue(verifyVariant(variants,new Variant(mt2,new Locale("en"),null))); assertTrue(verifyVariant(variants,new Variant(mt2,new Locale("fr"),null))); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testBuildLang(){ VariantListBuilderImpl vb=new VariantListBuilderImpl(); List variants=vb.languages(new Locale("en"),new Locale("fr")).add().build(); assertEquals("2 variants need to be created",2,variants.size()); assertTrue(verifyVariant(variants,new Variant(null,new Locale("en"),null))); assertTrue(verifyVariant(variants,new Variant(null,new Locale("en"),null))); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testBuildTypeAndEnc(){ VariantListBuilderImpl vb=new VariantListBuilderImpl(); MediaType mt1=new MediaType("*","*"); MediaType mt2=new MediaType("text","xml"); List variants=vb.mediaTypes(mt1,mt2).encodings("zip","identity").add().build(); assertEquals("4 variants need to be created",4,variants.size()); assertTrue(verifyVariant(variants,new Variant(mt1,(Locale)null,"zip"))); assertTrue(verifyVariant(variants,new Variant(mt1,(Locale)null,"identity"))); assertTrue(verifyVariant(variants,new Variant(mt2,(Locale)null,"zip"))); assertTrue(verifyVariant(variants,new Variant(mt2,(Locale)null,"identity"))); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testBuildLangAndEnc(){ VariantListBuilderImpl vb=new VariantListBuilderImpl(); List variants=vb.languages(new Locale("en"),new Locale("fr")).encodings("zip","identity").add().build(); assertEquals("4 variants need to be created",4,variants.size()); assertTrue(verifyVariant(variants,new Variant(null,new Locale("en"),"zip"))); assertTrue(verifyVariant(variants,new Variant(null,new Locale("en"),"identity"))); assertTrue(verifyVariant(variants,new Variant(null,new Locale("fr"),"zip"))); assertTrue(verifyVariant(variants,new Variant(null,new Locale("fr"),"identity"))); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testBuildAll(){ VariantListBuilderImpl vb=new VariantListBuilderImpl(); MediaType mt1=new MediaType("*","*"); MediaType mt2=new MediaType("text","xml"); List variants=vb.mediaTypes(mt1,mt2).languages(new Locale("en"),new Locale("fr")).encodings("zip","identity").add().build(); assertEquals("8 variants need to be created",8,variants.size()); assertTrue(verifyVariant(variants,new Variant(mt1,new Locale("en"),"zip"))); assertTrue(verifyVariant(variants,new Variant(mt1,new Locale("en"),"identity"))); assertTrue(verifyVariant(variants,new Variant(mt1,new Locale("fr"),"zip"))); assertTrue(verifyVariant(variants,new Variant(mt1,new Locale("fr"),"identity"))); assertTrue(verifyVariant(variants,new Variant(mt2,new Locale("en"),"zip"))); assertTrue(verifyVariant(variants,new Variant(mt2,new Locale("en"),"identity"))); assertTrue(verifyVariant(variants,new Variant(mt2,new Locale("fr"),"zip"))); assertTrue(verifyVariant(variants,new Variant(mt2,new Locale("fr"),"identity"))); }

Class: org.apache.cxf.jaxrs.json.basic.JsonMapObjectReaderWriterTest

InternalCallVerifier EqualityVerifier 
@Test public void testReadMap() throws Exception { String json="{\"a\":\"aValue\",\"b\":123,\"c\":[\"cValue\"]}"; Map map=new JsonMapObjectReaderWriter().fromJson(json); assertEquals(3,map.size()); assertEquals("aValue",map.get("a")); assertEquals(123L,map.get("b")); assertEquals(Collections.singletonList("cValue"),map.get("c")); }

InternalCallVerifier EqualityVerifier 
@Test public void testWriteMap() throws Exception { Map map=new LinkedHashMap(); map.put("a","aValue"); map.put("b",123); map.put("c",Collections.singletonList("cValue")); String json=new JsonMapObjectReaderWriter().toJson(map); assertEquals("{\"a\":\"aValue\",\"b\":123,\"c\":[\"cValue\"]}",json); }

Class: org.apache.cxf.jaxrs.lifecycle.PerRequestResourceProviderTest

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetInstance(){ PerRequestResourceProvider rp=new PerRequestResourceProvider(Customer.class); Message message=createMessage(); message.put(Message.QUERY_STRING,"a=aValue"); Customer c=(Customer)rp.getInstance(message); assertNotNull(c.getUriInfo()); assertEquals("aValue",c.getQueryParam()); assertTrue(c.isPostConstuctCalled()); rp.releaseInstance(message,c); assertTrue(c.isPreDestroyCalled()); }

Class: org.apache.cxf.jaxrs.model.ClassResourceInfoTest

EqualityVerifier 
@Test public void testGetConsume(){ ClassResourceInfo c=new ClassResourceInfo(TestClass.class); assertEquals("test/foo",c.getConsumeMime().get(0).toString()); c=new ClassResourceInfo(TestClass1.class); assertEquals("test/foo",c.getConsumeMime().get(0).toString()); c=new ClassResourceInfo(TestClass2.class); assertEquals("test/foo",c.getConsumeMime().get(0).toString()); }

InternalCallVerifier IdentityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetSameSubresource(){ ClassResourceInfo c=new ClassResourceInfo(TestClass.class); assertEquals("No subresources expected",0,c.getSubResources().size()); assertNull(c.findResource(TestClass.class,TestClass.class)); ClassResourceInfo c1=c.getSubResource(TestClass.class,TestClass.class); assertNotNull(c1); assertSame(c1,c.findResource(TestClass.class,TestClass.class)); assertSame(c1,c.getSubResource(TestClass.class,TestClass.class)); assertEquals("Single subresources expected",1,c.getSubResources().size()); }

InternalCallVerifier IdentityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetSubresourceSubclass(){ ClassResourceInfo c=new ClassResourceInfo(TestClass.class); assertEquals("No subresources expected",0,c.getSubResources().size()); assertNull(c.findResource(TestClass.class,TestClass1.class)); ClassResourceInfo c1=c.getSubResource(TestClass.class,TestClass1.class); assertNotNull(c1); assertSame(c1,c.findResource(TestClass.class,TestClass1.class)); assertNull(c.findResource(TestClass.class,TestClass2.class)); ClassResourceInfo c2=c.getSubResource(TestClass.class,TestClass2.class); assertNotNull(c2); assertSame(c2,c.findResource(TestClass.class,TestClass2.class)); assertSame(c2,c.getSubResource(TestClass.class,TestClass2.class)); assertNotSame(c1,c2); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSubresourceInheritProduces(){ ClassResourceInfo c=ResourceUtils.createClassResourceInfo(TestClass2.class,TestClass2.class,true,true); assertEquals("test/bar",c.getProduceMime().get(0).toString()); ClassResourceInfo sub=c.getSubResource(TestClass2.class,TestClass3.class); assertNotNull(sub); assertEquals("test/bar",sub.getProduceMime().get(0).toString()); sub=c.getSubResource(TestClass2.class,TestClass2.class); assertNotNull(sub); assertEquals("test/bar",sub.getProduceMime().get(0).toString()); }

EqualityVerifier 
@Test public void testGetProduce(){ ClassResourceInfo c=new ClassResourceInfo(TestClass.class); assertEquals("test/bar",c.getProduceMime().get(0).toString()); c=new ClassResourceInfo(TestClass1.class); assertEquals("test/bar",c.getProduceMime().get(0).toString()); c=new ClassResourceInfo(TestClass2.class); assertEquals("test/bar",c.getProduceMime().get(0).toString()); }

EqualityVerifier 
@Test public void testGetPath(){ ClassResourceInfo c=new ClassResourceInfo(TestClass.class); assertEquals("/bar",c.getPath().value()); c=new ClassResourceInfo(TestClass1.class); assertEquals("/bar",c.getPath().value()); c=new ClassResourceInfo(TestClass2.class); assertEquals("/bar",c.getPath().value()); }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testGetHttpContexts(){ ClassResourceInfo c=new ClassResourceInfo(TestClass.class,true); List fields=c.getContextFields(); Set> clses=new HashSet>(); for ( Field f : fields) { clses.add(f.getType()); } assertEquals("5 http context fields available",5,clses.size()); assertTrue("Wrong fields selected",clses.contains(HttpServletRequest.class) && clses.contains(HttpServletResponse.class) && clses.contains(ServletContext.class)&& clses.contains(UriInfo.class)&& clses.contains(HttpHeaders.class)); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testNameBindings(){ Application app=new TestApplication(); JAXRSServerFactoryBean bean=ResourceUtils.createApplication(app,true,true); ClassResourceInfo cri=bean.getServiceFactory().getClassResourceInfo().get(0); Set names=cri.getNameBindings(); assertEquals(Collections.singleton(CustomNameBinding.class.getName()),names); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testAllowedMethods(){ ClassResourceInfo c=ResourceUtils.createClassResourceInfo(TestClass3.class,TestClass3.class,false,false); Set methods=c.getAllowedMethods(); assertEquals(2,methods.size()); assertTrue(methods.contains("HEAD") && methods.contains("GET")); }

InternalCallVerifier EqualityVerifier 
@Test public void testSubresourceWithProduces(){ ClassResourceInfo parent=ResourceUtils.createClassResourceInfo(TestClass2.class,TestClass2.class,true,true); ClassResourceInfo c=ResourceUtils.createClassResourceInfo(TestClassWithProduces.class,TestClassWithProduces.class,true,true); c.setParent(parent); assertEquals("test/foo",c.getProduceMime().get(0).toString()); }

Class: org.apache.cxf.jaxrs.model.OperationResourceInfoTest

InternalCallVerifier EqualityVerifier 
@Test public void testProduceTypes() throws Exception { OperationResourceInfo ori1=new OperationResourceInfo(TestClass.class.getMethod("doIt",new Class[]{}),new ClassResourceInfo(TestClass.class)); List ctypes=ori1.getProduceTypes(); assertEquals("Single media type expected",1,ctypes.size()); assertEquals("Method produce type should be used","text/plain",ctypes.get(0).toString()); OperationResourceInfo ori2=new OperationResourceInfo(TestClass.class.getMethod("doThat",new Class[]{}),new ClassResourceInfo(TestClass.class)); ctypes=ori2.getProduceTypes(); assertEquals("Single media type expected",1,ctypes.size()); assertEquals("Class resource produce type should be used","text/xml",ctypes.get(0).toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testConsumeTypes() throws Exception { OperationResourceInfo ori1=new OperationResourceInfo(TestClass.class.getMethod("doIt",new Class[]{}),new ClassResourceInfo(TestClass.class)); List ctypes=ori1.getConsumeTypes(); assertEquals("Single media type expected",1,ctypes.size()); assertEquals("Class resource consume type should be used","application/xml",ctypes.get(0).toString()); OperationResourceInfo ori2=new OperationResourceInfo(TestClass.class.getMethod("doThat",new Class[]{}),new ClassResourceInfo(TestClass.class)); ctypes=ori2.getConsumeTypes(); assertEquals("Single media type expected",1,ctypes.size()); assertEquals("Method consume type should be used","application/atom+xml",ctypes.get(0).toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testComparator1() throws Exception { OperationResourceInfo ori1=new OperationResourceInfo(TestClass.class.getMethod("doIt",new Class[]{}),new ClassResourceInfo(TestClass.class)); ori1.setURITemplate(new URITemplate("/")); OperationResourceInfo ori2=new OperationResourceInfo(TestClass.class.getMethod("doThat",new Class[]{}),new ClassResourceInfo(TestClass.class)); ori2.setURITemplate(new URITemplate("/")); OperationResourceInfoComparator cmp=new OperationResourceInfoComparator(null,null); int result=cmp.compare(ori1,ori2); assertEquals(0,result); }

InternalCallVerifier EqualityVerifier 
@Test public void testComparator2() throws Exception { Message m=createMessage(); OperationResourceInfo ori1=new OperationResourceInfo(TestClass.class.getMethod("doIt",new Class[]{}),new ClassResourceInfo(TestClass.class)); ori1.setURITemplate(new URITemplate("/")); OperationResourceInfo ori2=new OperationResourceInfo(TestClass.class.getMethod("doThat",new Class[]{}),new ClassResourceInfo(TestClass.class)); ori2.setURITemplate(new URITemplate("/")); OperationResourceInfoComparator cmp=new OperationResourceInfoComparator(m,"POST",false,MediaType.WILDCARD_TYPE,Collections.singletonList(MediaType.WILDCARD_TYPE)); int result=cmp.compare(ori1,ori2); assertEquals(0,result); }

Class: org.apache.cxf.jaxrs.model.URITemplateTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testBaseTail3(){ URITemplate uriTemplate=new URITemplate("/{base:base.+suffix}/{tail}"); MultivaluedMap values=new MetadataMap(); assertFalse(uriTemplate.match("/base/tails",values)); assertFalse(uriTemplate.match("/base1/tails",values)); assertTrue(uriTemplate.match("/base1suffix/tails",values)); assertEquals("base1suffix",values.getFirst("base")); assertEquals("tails",values.getFirst("tail")); }

InternalCallVerifier EqualityVerifier 
@Test public void testVariables(){ URITemplate ut=new URITemplate("/foo/{a}/bar{c:\\d}{b:\\w}/{e}/{d}"); assertEquals(Arrays.asList("a","c","b","e","d"),ut.getVariables()); assertEquals(Arrays.asList("c","b"),ut.getCustomVariables()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testMatchWithMatrixOnClearPath2() throws Exception { URITemplate uriTemplate=new URITemplate("/customers/{id}/orders/{order}"); MultivaluedMap values=new MetadataMap(); assertTrue(uriTemplate.match("/customers;123456/123/orders;456/3",values)); assertEquals("123",values.getFirst("id")); assertEquals("3",values.getFirst("order")); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testMatchWithMatrixWithEmptyPath() throws Exception { URITemplate uriTemplate=new URITemplate("/"); MultivaluedMap values=new MetadataMap(); boolean match=uriTemplate.match("/;a=b",values); assertTrue(match); String finalGroup=values.getFirst(URITemplate.FINAL_MATCH_GROUP); assertEquals("/",finalGroup); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testBaseTail2(){ URITemplate uriTemplate=new URITemplate("/{base:.+base}/{tail}"); MultivaluedMap values=new MetadataMap(); assertFalse(uriTemplate.match("/base/tails",values)); assertFalse(uriTemplate.match("/base1/tails",values)); assertTrue(uriTemplate.match("/1base/tails",values)); assertEquals("1base",values.getFirst("base")); assertEquals("tails",values.getFirst("tail")); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testMatchWithMatrixAndTemplate() throws Exception { URITemplate uriTemplate=new URITemplate("/customers/{id}"); MultivaluedMap values=new MetadataMap(); boolean match=uriTemplate.match("/customers/123;123456/",values); assertTrue(match); String value=values.getFirst("id"); assertEquals("123;123456",value); }

EqualityVerifier 
@Test public void testEncodeLiteralCharactersNotVariable(){ URITemplate ut=new URITemplate("a {digit:[0-9]} b"); assertEquals("a%20{digit:[0-9]}%20b",ut.encodeLiteralCharacters(false)); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testMatchBasicTwoParametersVariation2() throws Exception { URITemplate uriTemplate=new URITemplate("/customers/name/{name}/dep/{department}"); MultivaluedMap values=new MetadataMap(); boolean match=uriTemplate.match("/customers/name/john/dep/CS",values); assertTrue(match); String name=values.getFirst("name"); String department=values.getFirst("department"); assertEquals("john",name); assertEquals("CS",department); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testMatchWithMatrixOnClearPath1() throws Exception { URITemplate uriTemplate=new URITemplate("/customers/{id}"); MultivaluedMap values=new MetadataMap(); boolean match=uriTemplate.match("/customers;123456/123/",values); assertTrue(match); String value=values.getFirst("id"); assertEquals("123",value); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testBaseTail1(){ URITemplate uriTemplate=new URITemplate("/{base:base.+}/{tail}"); MultivaluedMap values=new MetadataMap(); assertFalse(uriTemplate.match("/base/tails",values)); assertTrue(uriTemplate.match("/base1/tails",values)); assertEquals("base1",values.getFirst("base")); assertEquals("tails",values.getFirst("tail")); }

EqualityVerifier 
@Test public void testSubstituteMapExceeding() throws Exception { URITemplate ut=new URITemplate("/foo/{a}"); Map map=new HashMap(); map.put("b","baz"); map.put("a","blah"); assertEquals("Wrong substitution","/foo/blah",ut.substitute(map)); }

EqualityVerifier 
@Test public void testSubstituteMapSameVars() throws Exception { URITemplate ut=new URITemplate("/foo/{a}/{a}/{a}"); Map map=new HashMap(); map.put("a","bar"); assertEquals("Wrong substitution","/foo/bar/bar/bar",ut.substitute(map)); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testURITemplateWithSubResourceVariation2() throws Exception { URITemplate uriTemplate=new URITemplate("/customers"); MultivaluedMap values=new MetadataMap(); boolean match=uriTemplate.match("/customers/name/john/dep/CS",values); assertTrue(match); String subResourcePath=values.getFirst(URITemplate.FINAL_MATCH_GROUP); assertEquals("/name/john/dep/CS",subResourcePath); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testExpressionWithNestedGroup2() throws Exception { URITemplate uriTemplate=new URITemplate("/{resource:.+\\.(js|css|gif|png)}/bar"); MultivaluedMap values=new MetadataMap(); assertTrue(uriTemplate.match("/script.js/bar/baz",values)); assertEquals("script.js",values.getFirst("resource")); String finalPath=values.getFirst(URITemplate.FINAL_MATCH_GROUP); assertEquals("/baz",finalPath); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testTokenizerNoOpening(){ CurlyBraceTokenizer tok=new CurlyBraceTokenizer("foo}bar}baz"); assertEquals("foo}bar}baz",tok.next()); assertFalse(tok.hasNext()); }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testMatchWithMultipleMatrixParams() throws Exception { URITemplate uriTemplate=new URITemplate("renderwidget/id/{id}/type/{type}/size/{size}/locale/{locale}/{properties}"); MultivaluedMap values=new MetadataMap(); assertTrue(uriTemplate.match("renderwidget/id/1007/type/1/size/1/locale/en_US/properties;a=b",values)); assertEquals("1007",values.getFirst("id")); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testMatchWithMatrixOnClearPath3() throws Exception { URITemplate uriTemplate=new URITemplate("/{id}/customers/"); MultivaluedMap values=new MetadataMap(); boolean match=uriTemplate.match("/123/customers;123456/",values); assertTrue(match); String value=values.getFirst("id"); assertEquals("123",value); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testURITemplateWithSubResourceVariation3() throws Exception { URITemplate uriTemplate=new URITemplate("/books/{bookId}/"); MultivaluedMap values=new MetadataMap(); boolean match=uriTemplate.match("/books/123/chapter/1",values); assertTrue(match); String subResourcePath=values.getFirst(URITemplate.FINAL_MATCH_GROUP); assertEquals("/chapter/1",subResourcePath); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testMatchBasic() throws Exception { URITemplate uriTemplate=new URITemplate("/customers/{id}"); MultivaluedMap values=new MetadataMap(); boolean match=uriTemplate.match("/customers/123/",values); assertTrue(match); String value=values.getFirst("id"); assertEquals("123",value); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testExpressionWithNestedGroup() throws Exception { URITemplate uriTemplate=new URITemplate("/{resource:.+\\.(js|css|gif|png)}"); MultivaluedMap values=new MetadataMap(); assertTrue(uriTemplate.match("/script.js",values)); assertEquals("script.js",values.getFirst("resource")); String finalPath=values.getFirst(URITemplate.FINAL_MATCH_GROUP); assertEquals("/",finalPath); values.clear(); assertTrue(uriTemplate.match("/script.js/bar",values)); assertEquals("script.js",values.getFirst("resource")); finalPath=values.getFirst(URITemplate.FINAL_MATCH_GROUP); assertEquals("/bar",finalPath); values.clear(); assertFalse(uriTemplate.match("/script.pdf",values)); }

EqualityVerifier 
@Test public void testSubstituteListSameVars() throws Exception { URITemplate ut=new URITemplate("/foo/{a}/{a}/{a}"); List list=Arrays.asList("bar","baz","blah"); assertEquals("Wrong substitution","/foo/bar/baz/blah",ut.substitute(list)); }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testMatchWithMultipleMatrixParams2() throws Exception { URITemplate uriTemplate=new URITemplate("renderwidget/id/{id}/type/{type}/size/{size}/locale/{locale}/{properties}"); MultivaluedMap values=new MetadataMap(); assertTrue(uriTemplate.match("renderwidget/id/1007/type/1/size/1/locale/en_US/properties;numResults=1;foo=bar",values)); assertEquals("1007",values.getFirst("id")); }

EqualityVerifier 
@Test public void testSubstituteListExceeding() throws Exception { URITemplate ut=new URITemplate("/foo/{a}/{b}"); List list=Arrays.asList("bar","baz","blah"); assertEquals("Wrong substitution","/foo/bar/baz",ut.substitute(list)); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testURITemplateWithSubResourceVariation4() throws Exception { URITemplate uriTemplate=new URITemplate("/"); MultivaluedMap values=new MetadataMap(); boolean match=uriTemplate.match("/books/123/chapter/1",values); assertTrue(match); String subResourcePath=values.getFirst(URITemplate.FINAL_MATCH_GROUP); assertEquals("/books/123/chapter/1",subResourcePath); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testMultipleExpression2() throws Exception { URITemplate uriTemplate=new URITemplate("/books/{bookId:123}/chapter/{id}"); MultivaluedMap values=new MetadataMap(); boolean match=uriTemplate.match("/books/123/chapter/1",values); assertTrue(match); assertEquals("123",values.getFirst("bookId")); assertEquals("1",values.getFirst("id")); String subResourcePath=values.getFirst(URITemplate.FINAL_MATCH_GROUP); assertEquals("/",subResourcePath); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testMatchWithMatrixOnClearPath5() throws Exception { URITemplate uriTemplate=new URITemplate("/customers"); MultivaluedMap values=new MetadataMap(); assertTrue(uriTemplate.match("/customers;a=b",values)); String finalGroup=values.getFirst(URITemplate.FINAL_MATCH_GROUP); assertEquals("/",finalGroup); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testTokenizerNoClosing(){ CurlyBraceTokenizer tok=new CurlyBraceTokenizer("foo{bar}baz{blah"); assertEquals("foo",tok.next()); assertEquals("{bar}",tok.next()); assertEquals("baz",tok.next()); assertEquals("{blah",tok.next()); assertFalse(tok.hasNext()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testURITemplateWithSubResource() throws Exception { URITemplate uriTemplate=new URITemplate("/customers"); MultivaluedMap values=new MetadataMap(); boolean match=uriTemplate.match("/customers/123",values); assertTrue(match); String subResourcePath=values.getFirst(URITemplate.FINAL_MATCH_GROUP); assertEquals("/123",subResourcePath); }

EqualityVerifier 
@Test public void testUnclosedVariable(){ URITemplate ut=new URITemplate("/foo/{var/bar"); assertEquals("/foo/{var/bar",ut.getValue()); }

EqualityVerifier 
@Test public void testSubstituteList() throws Exception { URITemplate ut=new URITemplate("/foo/{a}/{b:\\d\\d}/{c}"); List list=Arrays.asList("foo","99","baz"); assertEquals("Wrong substitution","/foo/foo/99/baz",ut.substitute(list)); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testMatchBasicTwoParametersVariation1() throws Exception { URITemplate uriTemplate=new URITemplate("/customers/{name}/{department}"); MultivaluedMap values=new MetadataMap(); boolean match=uriTemplate.match("/customers/john/CS",values); assertTrue(match); String name=values.getFirst("name"); String department=values.getFirst("department"); assertEquals("john",name); assertEquals("CS",department); }

EqualityVerifier 
@Test public void testNestedCurlyBraces(){ URITemplate ut=new URITemplate("/foo/{hex:[0-9a-fA-F]{2}}"); Map map=new HashMap(); map.put("hex","FF"); assertEquals("Wrong substitution","/foo/FF",ut.substitute(map)); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testTokenizerNoBraces(){ CurlyBraceTokenizer tok=new CurlyBraceTokenizer("nobraces"); assertEquals("nobraces",tok.next()); assertFalse(tok.hasNext()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testExpressionWithNestedGroupAndManySegments() throws Exception { URITemplate uriTemplate=new URITemplate("/foo/{bar}{resource:(/format/[^/]+?)?}/baz"); MultivaluedMap values=new MetadataMap(); assertTrue(uriTemplate.match("/foo/1/format/2/baz/3",values)); assertEquals("1",values.getFirst("bar")); assertEquals("/format/2",values.getFirst("resource")); String finalPath=values.getFirst(URITemplate.FINAL_MATCH_GROUP); assertEquals("/3",finalPath); values.clear(); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testLiteralExpression() throws Exception { URITemplate uriTemplate=new URITemplate("/bar"); MultivaluedMap values=new MetadataMap(); assertTrue(uriTemplate.match("/bar/baz",values)); String finalPath=values.getFirst(URITemplate.FINAL_MATCH_GROUP); assertEquals("/baz",finalPath); }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testCompareRegExTemplates(){ URITemplate t1=new URITemplate("{entitySetName}{optionalParens: (\\(\\))?}"); URITemplate t2=new URITemplate("{entitySetName}{id: \\(.+?\\)}"); assertTrue(URITemplate.compareTemplates(t1,t2) < 0); assertTrue(URITemplate.compareTemplates(t2,t1) > 0); assertEquals(0,URITemplate.compareTemplates(t2,t2)); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testExpressionWithNestedGroupAndTwoVars2() throws Exception { URITemplate uriTemplate=new URITemplate("/foo/{bar}{resource:(/format/[^/]+?)?}"); MultivaluedMap values=new MetadataMap(); assertTrue(uriTemplate.match("/foo/1/format",values)); assertEquals("1",values.getFirst("bar")); assertEquals("/format",values.getFirst("resource")); String finalPath=values.getFirst(URITemplate.FINAL_MATCH_GROUP); assertEquals("/",finalPath); values.clear(); assertTrue(uriTemplate.match("/foo/1/format/2",values)); assertEquals("1",values.getFirst("bar")); assertEquals("/format/2",values.getFirst("resource")); finalPath=values.getFirst(URITemplate.FINAL_MATCH_GROUP); assertEquals("/",finalPath); values.clear(); assertTrue(uriTemplate.match("/foo/1",values)); assertEquals("1",values.getFirst("bar")); assertNull(values.getFirst("resource")); finalPath=values.getFirst(URITemplate.FINAL_MATCH_GROUP); assertEquals("/",finalPath); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testBasicCustomExpression2() throws Exception { URITemplate uriTemplate=new URITemplate("/books/{bookId:123}"); MultivaluedMap values=new MetadataMap(); boolean match=uriTemplate.match("/books/123/chapter/1",values); assertTrue(match); assertEquals("123",values.getFirst("bookId")); String subResourcePath=values.getFirst(URITemplate.FINAL_MATCH_GROUP); assertEquals("/chapter/1",subResourcePath); }

EqualityVerifier 
@Test public void testEncodeLiteralCharacters(){ URITemplate ut=new URITemplate("a {id} b"); assertEquals("a%20{id}%20b",ut.encodeLiteralCharacters(false)); }

EqualityVerifier 
@Test public void testSubstituteListIncomplete() throws Exception { URITemplate ut=new URITemplate("/foo/{a}/{c}/{b}/{d:\\w}"); List list=Arrays.asList("bar","baz"); assertEquals("Wrong substitution","/foo/bar/baz/{b}/{d:\\w}",ut.substitute(list)); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testBasicCustomExpression3() throws Exception { URITemplate uriTemplate=new URITemplate("/books/{bookId:\\d\\d\\d}"); MultivaluedMap values=new MetadataMap(); boolean match=uriTemplate.match("/books/123/chapter/1",values); assertTrue(match); assertEquals("123",values.getFirst("bookId")); String subResourcePath=values.getFirst(URITemplate.FINAL_MATCH_GROUP); assertEquals("/chapter/1",subResourcePath); }

EqualityVerifier 
@Test public void testSubstituteMap() throws Exception { URITemplate ut=new URITemplate("/foo/{a}/{b:\\d\\d}/{c}"); Map map=new HashMap(); map.put("c","foo"); map.put("b","11"); map.put("a","bar"); assertEquals("Wrong substitution","/foo/bar/11/foo",ut.substitute(map)); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testExpressionWithTwoVars() throws Exception { URITemplate uriTemplate=new URITemplate("/{tenant : [^/]*}/resource/{id}"); MultivaluedMap values=new MetadataMap(); boolean match=uriTemplate.match("/t1/resource/1",values); assertTrue(match); String tenant=values.getFirst("tenant"); assertEquals("t1",tenant); String id=values.getFirst("id"); assertEquals("1",id); String finalPath=values.getFirst(URITemplate.FINAL_MATCH_GROUP); assertEquals("/",finalPath); values.clear(); match=uriTemplate.match("//resource/1",values); assertTrue(match); tenant=values.getFirst("tenant"); assertEquals("",tenant); id=values.getFirst("id"); assertEquals("1",id); finalPath=values.getFirst(URITemplate.FINAL_MATCH_GROUP); assertEquals("/",finalPath); values.clear(); match=uriTemplate.match("/t1/resource/1/sub",values); assertTrue(match); tenant=values.getFirst("tenant"); assertEquals("t1",tenant); id=values.getFirst("id"); assertEquals("1",id); finalPath=values.getFirst(URITemplate.FINAL_MATCH_GROUP); assertEquals("/sub",finalPath); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testBasicCustomExpression4() throws Exception { URITemplate uriTemplate=new URITemplate("/books/{bookId:...\\.}"); MultivaluedMap values=new MetadataMap(); assertTrue(uriTemplate.match("/books/123.",values)); assertEquals("123.",values.getFirst("bookId")); values.clear(); assertTrue(uriTemplate.match("/books/abc.",values)); assertEquals("abc.",values.getFirst("bookId")); assertFalse(uriTemplate.match("/books/abcd",values)); assertFalse(uriTemplate.match("/books/abc",values)); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testMatchWithMatrixWithEmptyPath2() throws Exception { URITemplate uriTemplate=new URITemplate("/"); MultivaluedMap values=new MetadataMap(); boolean match=uriTemplate.match("/;a=b/b/c",values); assertTrue(match); String finalGroup=values.getFirst(URITemplate.FINAL_MATCH_GROUP); assertEquals("/b/c",finalGroup); }

EqualityVerifier 
@Test public void testUnopenedVariable(){ URITemplate ut=new URITemplate("/foo/var}/bar"); assertEquals("/foo/var}/bar",ut.getValue()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testExpressionWithNestedGroupAndTwoVars() throws Exception { URITemplate uriTemplate=new URITemplate("/foo/{bar}/{resource:.+\\.(js|css|gif|png)}"); MultivaluedMap values=new MetadataMap(); assertTrue(uriTemplate.match("/foo/1/script.js",values)); assertEquals("1",values.getFirst("bar")); assertEquals("script.js",values.getFirst("resource")); String finalPath=values.getFirst(URITemplate.FINAL_MATCH_GROUP); assertEquals("/",finalPath); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testTokenizerNesting(){ CurlyBraceTokenizer tok=new CurlyBraceTokenizer("foo{bar{baz}}blah"); assertEquals("foo",tok.next()); assertEquals("{bar{baz}}",tok.next()); assertEquals("blah",tok.next()); assertFalse(tok.hasNext()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testTokenizerNoNesting(){ CurlyBraceTokenizer tok=new CurlyBraceTokenizer("foo{bar}baz"); assertEquals("foo",tok.next()); assertEquals("{bar}",tok.next()); assertEquals("baz",tok.next()); assertFalse(tok.hasNext()); }

EqualityVerifier 
@Test public void testSubstituteMapSameVarWithPattern() throws Exception { URITemplate ut=new URITemplate("/foo/{a}/{a:\\d}"); Map map=new HashMap(); map.put("a","0"); assertEquals("Wrong substitution","/foo/0/0",ut.substitute(map)); }

Class: org.apache.cxf.jaxrs.model.wadl.ServerProviderFactoryTest

BooleanVerifier InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testCustomTestAndWadlHandler(){ ServerProviderFactory pf=ServerProviderFactory.getInstance(); assertEquals(1,pf.getPreMatchContainerRequestFilters().size()); assertTrue(pf.getPreMatchContainerRequestFilters().get(0).getProvider() instanceof WadlGenerator); List providers=new ArrayList(); WadlGenerator wg=new WadlGenerator(); providers.add(wg); TestHandler th=new TestHandler(); providers.add(th); pf.setUserProviders(providers); assertEquals(2,pf.getPreMatchContainerRequestFilters().size()); assertSame(wg,pf.getPreMatchContainerRequestFilters().get(0).getProvider()); assertSame(th,pf.getPreMatchContainerRequestFilters().get(1).getProvider()); }

BooleanVerifier InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testCustomTestHandler(){ ServerProviderFactory pf=ServerProviderFactory.getInstance(); assertEquals(1,pf.getPreMatchContainerRequestFilters().size()); assertTrue(pf.getPreMatchContainerRequestFilters().get(0).getProvider() instanceof WadlGenerator); TestHandler th=new TestHandler(); pf.setUserProviders(Collections.singletonList(th)); assertEquals(2,pf.getPreMatchContainerRequestFilters().size()); assertTrue(pf.getPreMatchContainerRequestFilters().get(0).getProvider() instanceof WadlGenerator); assertSame(th,pf.getPreMatchContainerRequestFilters().get(1).getProvider()); }

BooleanVerifier InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testCustomWadlHandler(){ ServerProviderFactory pf=ServerProviderFactory.getInstance(); assertEquals(1,pf.getPreMatchContainerRequestFilters().size()); assertTrue(pf.getPreMatchContainerRequestFilters().get(0).getProvider() instanceof WadlGenerator); WadlGenerator wg=new WadlGenerator(); pf.setUserProviders(Collections.singletonList(wg)); assertEquals(1,pf.getPreMatchContainerRequestFilters().size()); assertTrue(pf.getPreMatchContainerRequestFilters().get(0).getProvider() instanceof WadlGenerator); assertSame(wg,pf.getPreMatchContainerRequestFilters().get(0).getProvider()); }

Class: org.apache.cxf.jaxrs.model.wadl.WadlGeneratorJsonTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testWadlInJsonFormat() throws Exception { ClassResourceInfo cri=ResourceUtils.createClassResourceInfo(BookChapters.class,BookChapters.class,true,true); final Message m=mockMessage("http://localhost:8080/baz","/bookstore/1",WadlGenerator.WADL_QUERY,cri); Map> headers=new HashMap>(); headers.put("Accept",Collections.singletonList("application/json")); m.put(Message.PROTOCOL_HEADERS,headers); WadlGenerator wg=new WadlGenerator(){ public void filter( ContainerRequestContext context){ super.doFilter(context,m); } } ; wg.setUseJaxbContextForQnames(false); wg.setIgnoreMessageWriters(false); wg.setExternalLinks(Collections.singletonList("json.schema")); Response r=handleRequest(wg,m); assertEquals("application/json",r.getMetadata().getFirst("Content-Type").toString()); ByteArrayOutputStream os=new ByteArrayOutputStream(); new JSONProvider().writeTo((Document)r.getEntity(),Document.class,Document.class,new Annotation[]{},MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),os); String s=os.toString(); String expected1="{\"application\":{\"grammars\":{\"include\":{\"@href\":\"http://localhost:8080/baz" + "/json.schema\"}},\"resources\":{\"@base\":\"http://localhost:8080/baz\"," + "\"resource\":{\"@path\":\"/bookstore/{id}\""; assertTrue(s.startsWith(expected1)); String expected2="\"response\":{\"representation\":[{\"@mediaType\":\"application/xml\"}," + "{\"@element\":\"Chapter\",\"@mediaType\":\"application/json\"}]}"; assertTrue(s.contains(expected2)); }

Class: org.apache.cxf.jaxrs.model.wadl.WadlGeneratorTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testMultipleRootResources() throws Exception { WadlGenerator wg=new WadlGenerator(); wg.setDefaultMediaType(WadlGenerator.WADL_TYPE.toString()); ClassResourceInfo cri1=ResourceUtils.createClassResourceInfo(BookStore.class,BookStore.class,true,true); ClassResourceInfo cri2=ResourceUtils.createClassResourceInfo(Orders.class,Orders.class,true,true); List cris=new ArrayList(); cris.add(cri1); cris.add(cri2); Message m=mockMessage("http://localhost:8080/baz","",WadlGenerator.WADL_QUERY,cris); Response r=handleRequest(wg,m); assertEquals(WadlGenerator.WADL_TYPE.toString(),r.getMetadata().getFirst(HttpHeaders.CONTENT_TYPE).toString()); String wadl=r.getEntity().toString(); Document doc=StaxUtils.read(new StringReader(wadl)); checkGrammars(doc.getDocumentElement(),"thebook","books","thebook2s","thebook2","thechapter"); List els=getWadlResourcesInfo(doc,"http://localhost:8080/baz",2); checkBookStoreInfo(els.get(0),"prefix1:thebook","prefix1:thebook2","prefix1:thechapter"); Element orderResource=els.get(1); assertEquals("/orders",orderResource.getAttribute("path")); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testCustomSchemaWithImportJaxbContextPrefixes() throws Exception { WadlGenerator wg=new WadlGenerator(); wg.setSchemaLocations(Collections.singletonList("classpath:/books.xsd")); ClassResourceInfo cri=ResourceUtils.createClassResourceInfo(BookStore.class,BookStore.class,true,true); Message m=mockMessage("http://localhost:8080/baz","/bar",WadlGenerator.WADL_QUERY,cri); Response r=handleRequest(wg,m); checkResponse(r); Document doc=StaxUtils.read(new StringReader(r.getEntity().toString())); List grammarEls=DOMUtils.getChildrenWithName(doc.getDocumentElement(),WadlGenerator.WADL_NS,"grammars"); assertEquals(1,grammarEls.size()); List schemasEls=DOMUtils.getChildrenWithName(grammarEls.get(0),Constants.URI_2001_SCHEMA_XSD,"schema"); assertEquals(1,schemasEls.size()); assertEquals("http://books",schemasEls.get(0).getAttribute("targetNamespace")); List elementEls=DOMUtils.getChildrenWithName(schemasEls.get(0),Constants.URI_2001_SCHEMA_XSD,"element"); assertEquals(1,elementEls.size()); assertTrue(checkElement(elementEls,"books","books")); List complexTypesEls=DOMUtils.getChildrenWithName(schemasEls.get(0),Constants.URI_2001_SCHEMA_XSD,"complexType"); assertEquals(1,complexTypesEls.size()); assertTrue(checkComplexType(complexTypesEls,"books")); List importEls=DOMUtils.getChildrenWithName(schemasEls.get(0),Constants.URI_2001_SCHEMA_XSD,"import"); assertEquals(1,importEls.size()); assertEquals("http://localhost:8080/baz/book1.xsd",importEls.get(0).getAttribute("schemaLocation")); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testRootResourceWithSingleSlash() throws Exception { WadlGenerator wg=new WadlGenerator(); ClassResourceInfo cri=ResourceUtils.createClassResourceInfo(BookStoreWithSingleSlash.class,BookStoreWithSingleSlash.class,true,true); Message m=mockMessage("http://localhost:8080/baz","/",WadlGenerator.WADL_QUERY,cri); Response r=handleRequest(wg,m); checkResponse(r); Document doc=StaxUtils.read(new StringReader(r.getEntity().toString())); List rootEls=getWadlResourcesInfo(doc,"http://localhost:8080/baz",1); assertEquals(1,rootEls.size()); Element resource=rootEls.get(0); assertEquals("/",resource.getAttribute("path")); List resourceEls=DOMUtils.getChildrenWithName(resource,WadlGenerator.WADL_NS,"resource"); assertEquals(1,resourceEls.size()); assertEquals("book",resourceEls.get(0).getAttribute("path")); verifyParameters(resourceEls.get(0),1,new Param("id","template","xs:int")); checkGrammars(doc.getDocumentElement(),"thebook",null,"thechapter"); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testTwoSchemasSameNs() throws Exception { WadlGenerator wg=new WadlGenerator(); wg.setApplicationTitle("My Application"); wg.setNamespacePrefix("ns"); ClassResourceInfo cri=ResourceUtils.createClassResourceInfo(TestResource.class,TestResource.class,true,true); Message m=mockMessage("http://localhost:8080/baz","/",WadlGenerator.WADL_QUERY,cri); Response r=handleRequest(wg,m); checkResponse(r); Document doc=StaxUtils.read(new StringReader(r.getEntity().toString())); checkDocs(doc.getDocumentElement(),"My Application","",""); List grammarEls=DOMUtils.getChildrenWithName(doc.getDocumentElement(),WadlGenerator.WADL_NS,"grammars"); assertEquals(1,grammarEls.size()); List schemasEls=DOMUtils.getChildrenWithName(grammarEls.get(0),Constants.URI_2001_SCHEMA_XSD,"schema"); assertEquals(2,schemasEls.size()); assertEquals("http://example.com/test",schemasEls.get(0).getAttribute("targetNamespace")); assertEquals("http://example.com/test",schemasEls.get(1).getAttribute("targetNamespace")); List reps=DOMUtils.findAllElementsByTagNameNS(doc.getDocumentElement(),WadlGenerator.WADL_NS,"representation"); assertEquals(2,reps.size()); assertEquals("ns1:testCompositeObject",reps.get(0).getAttribute("element")); assertEquals("ns1:testCompositeObject",reps.get(1).getAttribute("element")); }

Class: org.apache.cxf.jaxrs.provider.BinaryDataProviderTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@SuppressWarnings({"unchecked","rawtypes"}) @Test public void testReadFrom() throws Exception { MessageBodyReader p=new BinaryDataProvider(); byte[] bytes=(byte[])p.readFrom(byte[].class,byte[].class,new Annotation[]{},MediaType.APPLICATION_OCTET_STREAM_TYPE,new MetadataMap(),new ByteArrayInputStream("hi".getBytes())); assertTrue(Arrays.equals(new String("hi").getBytes(),bytes)); InputStream is=(InputStream)p.readFrom(InputStream.class,InputStream.class,new Annotation[]{},MediaType.APPLICATION_OCTET_STREAM_TYPE,new MetadataMap(),new ByteArrayInputStream("hi".getBytes())); bytes=IOUtils.readBytesFromStream(is); assertTrue(Arrays.equals(new String("hi").getBytes(),bytes)); Reader r=(Reader)p.readFrom(Reader.class,Reader.class,new Annotation[]{},MediaType.APPLICATION_OCTET_STREAM_TYPE,new MetadataMap(),new ByteArrayInputStream("hi".getBytes())); assertEquals(IOUtils.toString(r),"hi"); StreamingOutput so=(StreamingOutput)p.readFrom(StreamingOutput.class,StreamingOutput.class,new Annotation[]{},MediaType.APPLICATION_OCTET_STREAM_TYPE,new MetadataMap(),new ByteArrayInputStream("hi".getBytes())); ByteArrayOutputStream baos=new ByteArrayOutputStream(); so.write(baos); bytes=baos.toByteArray(); assertTrue(Arrays.equals(new String("hi").getBytes(),bytes)); }

Class: org.apache.cxf.jaxrs.provider.DataSourceProviderTest

EqualityVerifier 
@Test public void testWriteDataSource() throws Exception { DataSourceProvider p=new DataSourceProvider(); DataSource ds=new InputStreamDataSource(new ByteArrayInputStream("image".getBytes()),"image/png"); ByteArrayOutputStream os=new ByteArrayOutputStream(); MultivaluedMap outHeaders=new MetadataMap(); p.writeTo(ds,DataSource.class,DataSource.class,new Annotation[]{},MediaType.valueOf("image/png"),outHeaders,os); assertEquals("image",os.toString()); assertEquals(0,outHeaders.size()); }

InternalCallVerifier EqualityVerifier 
@Test public void testReadDataHandler() throws Exception { DataSourceProvider p=new DataSourceProvider(); DataHandler ds=(DataHandler)p.readFrom(DataHandler.class,null,new Annotation[]{},MediaType.valueOf("image/png"),new MetadataMap(),new ByteArrayInputStream("image".getBytes())); assertEquals("image",IOUtils.readStringFromStream(ds.getDataSource().getInputStream())); }

InternalCallVerifier EqualityVerifier 
@Test public void testReadDataSource() throws Exception { DataSourceProvider p=new DataSourceProvider(); DataSource ds=(DataSource)p.readFrom(DataSource.class,null,new Annotation[]{},MediaType.valueOf("image/png"),new MetadataMap(),new ByteArrayInputStream("image".getBytes())); assertEquals("image",IOUtils.readStringFromStream(ds.getInputStream())); }

EqualityVerifier 
@Test public void testWriteDataSourceWithDiffCT() throws Exception { DataSourceProvider p=new DataSourceProvider(); p.setUseDataSourceContentType(true); DataSource ds=new InputStreamDataSource(new ByteArrayInputStream("image".getBytes()),"image/png"); ByteArrayOutputStream os=new ByteArrayOutputStream(); MultivaluedMap outHeaders=new MetadataMap(); p.writeTo(ds,DataSource.class,DataSource.class,new Annotation[]{},MediaType.valueOf("image/jpeg"),outHeaders,os); assertEquals("image",os.toString()); assertEquals("image/png",outHeaders.getFirst("Content-Type")); }

EqualityVerifier 
@Test public void testWriteDataHandler() throws Exception { DataSourceProvider p=new DataSourceProvider(); DataHandler ds=new DataHandler(new InputStreamDataSource(new ByteArrayInputStream("image".getBytes()),"image/png")); ByteArrayOutputStream os=new ByteArrayOutputStream(); p.writeTo(ds,DataHandler.class,DataHandler.class,new Annotation[]{},MediaType.valueOf("image/png"),new MetadataMap(),os); assertEquals("image",os.toString()); }

Class: org.apache.cxf.jaxrs.provider.FormEncodingProviderTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@SuppressWarnings("unchecked") @Test public void testEncoded() throws Exception { String values="foo=1+2&bar=1+3"; @SuppressWarnings("rawtypes") FormEncodingProvider ferp=new FormEncodingProvider(); MultivaluedMap mvMap=(MultivaluedMap)ferp.readFrom(MultivaluedMap.class,null,new Annotation[]{CustomMap.class.getAnnotations()[0]},MediaType.APPLICATION_FORM_URLENCODED_TYPE,null,new ByteArrayInputStream(values.getBytes())); assertEquals("Wrong entry for foo","1+2",mvMap.getFirst("foo")); assertEquals("Wrong entry for boo","1+3",mvMap.getFirst("bar")); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testMultiLines() throws Exception { String values="foo=1+2&bar=line1%0D%0Aline+2&baz=4"; FormEncodingProvider ferp=new FormEncodingProvider(); MultivaluedMap mvMap=ferp.readFrom(CustomMap.class,null,new Annotation[]{},MediaType.APPLICATION_FORM_URLENCODED_TYPE,null,new ByteArrayInputStream(values.getBytes())); assertEquals(3,mvMap.size()); assertEquals(1,mvMap.get("foo").size()); assertEquals(1,mvMap.get("bar").size()); assertEquals(1,mvMap.get("baz").size()); assertEquals("Wrong entry for foo","1 2",mvMap.getFirst("foo")); assertEquals("Wrong entry line for bar",HttpUtils.urlDecode("line1%0D%0Aline+2"),mvMap.get("bar").get(0)); assertEquals("Wrong entry for baz","4",mvMap.getFirst("baz")); }

APIUtilityVerifier EqualityVerifier 
@Test public void testWriteMultipleValues2() throws Exception { MultivaluedMap mvMap=new MetadataMap(); mvMap.add("a","a1"); mvMap.add("a","a2"); mvMap.add("b","b1"); FormEncodingProvider> ferp=new FormEncodingProvider>(); ByteArrayOutputStream bos=new ByteArrayOutputStream(); ferp.writeTo(mvMap,MultivaluedMap.class,MultivaluedMap.class,new Annotation[0],MediaType.APPLICATION_FORM_URLENCODED_TYPE,new MetadataMap(),bos); String result=bos.toString(); assertEquals("Wrong value","a=a1&a=a2&b=b1",result); }

APIUtilityVerifier EqualityVerifier 
@Test public void testWriteMultipleValues() throws Exception { MultivaluedMap mvMap=new MetadataMap(); mvMap.add("a","a1"); mvMap.add("a","a2"); FormEncodingProvider> ferp=new FormEncodingProvider>(); ByteArrayOutputStream bos=new ByteArrayOutputStream(); ferp.writeTo(mvMap,MultivaluedMap.class,MultivaluedMap.class,new Annotation[0],MediaType.APPLICATION_FORM_URLENCODED_TYPE,new MetadataMap(),bos); String result=bos.toString(); assertEquals("Wrong value","a=a1&a=a2",result); }

InternalCallVerifier EqualityVerifier 
@SuppressWarnings("unchecked") @Test public void testReadFromMultiples() throws Exception { InputStream is=getClass().getResourceAsStream("multiValPostBody.txt"); @SuppressWarnings("rawtypes") FormEncodingProvider ferp=new FormEncodingProvider(); MultivaluedMap mvMap=(MultivaluedMap)ferp.readFrom(MultivaluedMap.class,null,new Annotation[]{},MediaType.APPLICATION_FORM_URLENCODED_TYPE,null,is); List vals=mvMap.get("foo"); assertEquals("Wrong size for foo params",2,vals.size()); assertEquals("Wrong size for foo params",1,mvMap.get("boo").size()); assertEquals("Wrong entry for foo 0","bar",vals.get(0)); assertEquals("Wrong entry for foo 1","bar2",vals.get(1)); assertEquals("Wrong entry for boo","far",mvMap.getFirst("boo")); }

EqualityVerifier 
@Test public void testAnnotations(){ FormEncodingProvider
ferp=new FormEncodingProvider(); assertEquals("application/x-www-form-urlencoded",ferp.getClass().getAnnotation(Consumes.class).value()[0]); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testCustomMapImpl() throws Exception { String values="foo=1+2&bar=1+3&baz=4"; FormEncodingProvider ferp=new FormEncodingProvider(); MultivaluedMap mvMap=ferp.readFrom(CustomMap.class,null,new Annotation[]{},MediaType.APPLICATION_FORM_URLENCODED_TYPE,null,new ByteArrayInputStream(values.getBytes())); assertEquals(3,mvMap.size()); assertEquals(1,mvMap.get("foo").size()); assertEquals(1,mvMap.get("bar").size()); assertEquals(1,mvMap.get("baz").size()); assertEquals("Wrong entry for foo","1 2",mvMap.getFirst("foo")); assertEquals("Wrong entry for boo","1 3",mvMap.getFirst("bar")); assertEquals("Wrong entry for baz","4",mvMap.getFirst("baz")); }

APIUtilityVerifier EqualityVerifier 
@Test public void testWriteForm() throws Exception { Form form=new Form(new MetadataMap()); ByteArrayOutputStream bos=new ByteArrayOutputStream(); FormEncodingProvider ferp=new FormEncodingProvider(); ferp.writeTo(form.param("a","a1").param("b","b1"),Form.class,Form.class,new Annotation[0],MediaType.APPLICATION_FORM_URLENCODED_TYPE,new MetadataMap(),bos); String result=bos.toString(); assertEquals("Wrong value","a=a1&b=b1",result); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@SuppressWarnings("unchecked") @Test public void testReadFromISO() throws Exception { String eWithAcute="\u00E9"; String helloStringUTF16="name=F" + eWithAcute + "lix"; byte[] iso88591bytes=helloStringUTF16.getBytes("ISO-8859-1"); String helloStringISO88591=new String(iso88591bytes,"ISO-8859-1"); @SuppressWarnings("rawtypes") FormEncodingProvider ferp=new FormEncodingProvider(); MultivaluedMap mvMap=(MultivaluedMap)ferp.readFrom(MultivaluedMap.class,null,new Annotation[]{},MediaType.valueOf(MediaType.APPLICATION_FORM_URLENCODED + ";charset=ISO-8859-1"),null,new ByteArrayInputStream(iso88591bytes)); String value=mvMap.getFirst("name"); assertEquals(helloStringISO88591,"name=" + value); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@SuppressWarnings("unchecked") @Test public void testReadChineeseChars() throws Exception { String s="name=中文"; @SuppressWarnings("rawtypes") FormEncodingProvider ferp=new FormEncodingProvider(); MultivaluedMap mvMap=(MultivaluedMap)ferp.readFrom(MultivaluedMap.class,null,new Annotation[]{},MediaType.valueOf(MediaType.APPLICATION_FORM_URLENCODED + ";charset=UTF-8"),null,new ByteArrayInputStream(s.getBytes(StandardCharsets.UTF_8))); String value=mvMap.getFirst("name"); assertEquals(s,"name=" + value); }

InternalCallVerifier EqualityVerifier 
@Test public void testReadFrom() throws Exception { @SuppressWarnings("rawtypes") FormEncodingProvider ferp=new FormEncodingProvider(); InputStream is=getClass().getResourceAsStream("singleValPostBody.txt"); @SuppressWarnings("unchecked") MultivaluedMap mvMap=(MultivaluedMap)ferp.readFrom(MultivaluedMap.class,null,new Annotation[]{},MediaType.APPLICATION_FORM_URLENCODED_TYPE,null,is); assertEquals("Wrong entry for foo","bar",mvMap.getFirst("foo")); assertEquals("Wrong entry for boo","far",mvMap.getFirst("boo")); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@SuppressWarnings("unchecked") @Test public void testDecoded() throws Exception { String values="foo=1+2&bar=1+3"; @SuppressWarnings("rawtypes") FormEncodingProvider ferp=new FormEncodingProvider(); @SuppressWarnings("rawtypes") MultivaluedMap mvMap=(MultivaluedMap)ferp.readFrom((Class)MultivaluedMap.class,null,new Annotation[]{},MediaType.APPLICATION_FORM_URLENCODED_TYPE,null,new ByteArrayInputStream(values.getBytes())); assertEquals("Wrong entry for foo","1 2",mvMap.getFirst("foo")); assertEquals("Wrong entry for boo","1 3",mvMap.getFirst("bar")); }

InternalCallVerifier EqualityVerifier 
@Test public void testReadFromForm() throws Exception { FormEncodingProvider ferp=new FormEncodingProvider(); InputStream is=getClass().getResourceAsStream("singleValPostBody.txt"); Form form=ferp.readFrom(Form.class,null,new Annotation[]{},MediaType.APPLICATION_FORM_URLENCODED_TYPE,null,is); MultivaluedMap mvMap=form.asMap(); assertEquals("Wrong entry for foo","bar",mvMap.getFirst("foo")); assertEquals("Wrong entry for boo","far",mvMap.getFirst("boo")); }

APIUtilityVerifier EqualityVerifier 
@Test public void testWrite() throws Exception { MultivaluedMap mvMap=new MetadataMap(); mvMap.add("a","a1"); mvMap.add("b","b1"); ByteArrayOutputStream bos=new ByteArrayOutputStream(); FormEncodingProvider> ferp=new FormEncodingProvider>(); ferp.writeTo(mvMap,MultivaluedMap.class,MultivaluedMap.class,new Annotation[0],MediaType.APPLICATION_FORM_URLENCODED_TYPE,new MetadataMap(),bos); String result=bos.toString(); assertEquals("Wrong value","a=a1&b=b1",result); }

Class: org.apache.cxf.jaxrs.provider.JAXBElementProviderTest

EqualityVerifier 
@Test public void testOutAppendNsElementBeforeLocal() throws Exception { JAXBElementProvider provider=new JAXBElementProvider(); Map map=new HashMap(); map.put("tagVO","{http://tagsvo2}t"); provider.setOutAppendElements(map); TagVO tag=new TagVO("A","B"); ByteArrayOutputStream bos=new ByteArrayOutputStream(); provider.writeTo(tag,TagVO.class,TagVO.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),bos); String expected="" + "BA"; assertEquals(expected,bos.toString()); }

EqualityVerifier 
@Test public void testSetMarshallProperties() throws Exception { Map props=new HashMap(); props.put(Marshaller.JAXB_FORMATTED_OUTPUT,true); props.put(Marshaller.JAXB_SCHEMA_LOCATION,"foo.xsd"); final TestMarshaller m=new TestMarshaller(); JAXBElementProvider provider=new JAXBElementProvider(){ @Override protected Marshaller createMarshaller( Object obj, Class cls, Type genericType, String enc) throws JAXBException { return m; } } ; provider.setMarshallerProperties(props); provider.writeTo("123",String.class,String.class,new Annotation[]{},MediaType.APPLICATION_XML_TYPE,new MetadataMap(),new ByteArrayOutputStream()); assertEquals("Marshall properties have not been set",props,m.getProperties()); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testReadMalformedXML() throws Exception { JAXBElementProvider provider=new JAXBElementProvider(); try { provider.readFrom(Book.class,Book.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),new ByteArrayInputStream("".getBytes())); fail("404 is expected"); } catch ( WebApplicationException ex) { assertEquals(400,ex.getResponse().getStatus()); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testInNsElementsFromLocals() throws Exception { String data="" + "BA"; JAXBElementProvider provider=new JAXBElementProvider(); Map map=new HashMap(); map.put("tagholder","{http://tags}tagholder"); map.put("thetag","{http://tags}thetag"); provider.setInTransformElements(map); ByteArrayInputStream is=new ByteArrayInputStream(data.getBytes()); Object o=provider.readFrom(TagVO2Holder.class,TagVO2Holder.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),is); TagVO2Holder holder=(TagVO2Holder)o; TagVO2 tag2=holder.getTagValue(); assertEquals("A",tag2.getName()); assertEquals("B",tag2.getGroup()); }

EqualityVerifier 
@Test public void testOutAppendElementsSameNs() throws Exception { JAXBElementProvider provider=new JAXBElementProvider(); Map prefixes=new HashMap(); prefixes.put("http://tags","ns2"); provider.setNamespacePrefixes(prefixes); Map map=new HashMap(); map.put("{http://tags}thetag","{http://tags}t"); provider.setOutAppendElements(map); TagVO2 tag=new TagVO2("A","B"); ByteArrayOutputStream bos=new ByteArrayOutputStream(); provider.writeTo(tag,TagVO2.class,TagVO2.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),bos); String expected="" + "BA" + ""; assertEquals(expected,bos.toString()); }

EqualityVerifier 
@Test public void testDropQualifiedElements() throws Exception { JAXBElementProvider provider=new JAXBElementProvider(); List list=new ArrayList(); list.add("{http://tags}thetag"); provider.setOutDropElements(list); Map map=new HashMap(); map.put("name",""); provider.setOutTransformElements(map); TagVO2 tag=new TagVO2("A","B"); ByteArrayOutputStream bos=new ByteArrayOutputStream(); provider.writeTo(tag,TagVO2.class,TagVO2.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),bos); String expected="" + "B"; assertEquals(expected,bos.toString()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testWriteWithoutXmlRootElementWithPackageInfo() throws Exception { JAXBElementProvider provider=new JAXBElementProvider(); provider.setMarshallAsJaxbElement(true); Book2NoRootElement book=new Book2NoRootElement(333); ByteArrayOutputStream bos=new ByteArrayOutputStream(); provider.writeTo(book,Book2NoRootElement.class,Book2NoRootElement.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),bos); assertTrue(bos.toString().contains("book2")); assertTrue(bos.toString().contains("http://superbooks")); provider.setUnmarshallAsJaxbElement(true); ByteArrayInputStream is=new ByteArrayInputStream(bos.toByteArray()); Book2NoRootElement book2=provider.readFrom(Book2NoRootElement.class,Book2NoRootElement.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),is); assertEquals(book2.getId(),book.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testReadParamJAXBElement() throws Exception { String xml="" + "a"; JAXBElementProvider provider=new JAXBElementProvider(); ParamJAXBElement jaxbElement=provider.readFrom(ParamJAXBElement.class,ParamJAXBElement.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8))); ParamType param=jaxbElement.getValue(); assertEquals("a",param.getComment()); }

EqualityVerifier 
@Test public void testOutAppendLocalBeforeLocal() throws Exception { JAXBElementProvider provider=new JAXBElementProvider(); Map map=new HashMap(); map.put("tagVO","supertag"); provider.setOutAppendElements(map); TagVO tag=new TagVO("A","B"); ByteArrayOutputStream bos=new ByteArrayOutputStream(); provider.writeTo(tag,TagVO.class,TagVO.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),bos); String expected="" + "BA"; assertEquals(expected,bos.toString()); }

EqualityVerifier 
@Test public void testOutAttributesAsElementsForList() throws Exception { JAXBElementProvider> provider=new JAXBElementProvider>(); provider.setMessageContext(new MessageContextImpl(createMessage())); provider.setCollectionWrapperName("tagholders"); Map map=new HashMap(); map.put("{http://tags}*","*"); provider.setOutTransformElements(map); provider.setAttributesToElements(true); TagVO2 tag=new TagVO2("A","B"); TagVO2Holder holder=new TagVO2Holder(); holder.setTag(tag); List list=new ArrayList(); list.add(holder); ParameterizedType type=new ParameterizedType(){ public Type getRawType(){ return List.class; } public Type getOwnerType(){ return null; } public Type[] getActualTypeArguments(){ return new Type[]{TagVO2Holder.class}; } } ; ByteArrayOutputStream bos=new ByteArrayOutputStream(); provider.writeTo(list,ArrayList.class,type,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),bos); String expected="" + "attribute" + "BA"; assertEquals(expected,bos.toString()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testWriteWithoutXmlRootElementObjectFactory() throws Exception { JAXBElementProvider provider=new JAXBElementProvider(); provider.setJaxbElementClassMap(Collections.singletonMap(org.apache.cxf.jaxrs.fortest.jaxb.SuperBook2.class.getName(),"{http://books}SuperBook2")); org.apache.cxf.jaxrs.fortest.jaxb.SuperBook2 b=new org.apache.cxf.jaxrs.fortest.jaxb.SuperBook2("CXF in Action",123L,124L); ByteArrayOutputStream bos=new ByteArrayOutputStream(); provider.writeTo(b,org.apache.cxf.jaxrs.fortest.jaxb.SuperBook2.class,org.apache.cxf.jaxrs.fortest.jaxb.SuperBook2.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),bos); JAXBElementProvider provider2=new JAXBElementProvider(); ByteArrayInputStream is=new ByteArrayInputStream(bos.toByteArray()); org.apache.cxf.jaxrs.fortest.jaxb.SuperBook2 book=provider2.readFrom(org.apache.cxf.jaxrs.fortest.jaxb.SuperBook2.class,org.apache.cxf.jaxrs.fortest.jaxb.SuperBook2.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),is); assertEquals(124L,book.getSuperId()); }

EqualityVerifier 
@Test public void testOutElementsMapLocalNsToLocalWildcard() throws Exception { JAXBElementProvider provider=new JAXBElementProvider(); Map map=new HashMap(); map.put("{http://tags}*","*"); provider.setOutTransformElements(map); TagVO2 tag=new TagVO2("A","B"); TagVO2Holder holder=new TagVO2Holder(); holder.setTag(tag); ByteArrayOutputStream bos=new ByteArrayOutputStream(); provider.writeTo(holder,TagVO2Holder.class,TagVO2Holder.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),bos); String expected="" + "BA"; assertEquals(expected,bos.toString()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@SuppressWarnings({"rawtypes","unchecked"}) @Test public void testReadJAXBElement() throws Exception { String xml="123CXF in Action"; JAXBElementProvider provider=new JAXBElementProvider(); JAXBElement jaxbElement=provider.readFrom(JAXBElement.class,Book.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8))); Book book=jaxbElement.getValue(); assertEquals(123L,book.getId()); assertEquals("CXF in Action",book.getName()); }

EqualityVerifier 
@Test public void testWriteCollectionWithoutXmlRootElement() throws Exception { JAXBElementProvider> provider=new JAXBElementProvider>(); Map prefixes=new HashMap(); prefixes.put("http://superbooks","ns1"); prefixes.put("http://books","ns2"); provider.setNamespacePrefixes(prefixes); provider.setCollectionWrapperName("{http://superbooks}SuperBooks"); provider.setJaxbElementClassMap(Collections.singletonMap(org.apache.cxf.jaxrs.fortest.jaxb.SuperBook.class.getName(),"{http://superbooks}SuperBook")); org.apache.cxf.jaxrs.fortest.jaxb.SuperBook b=new org.apache.cxf.jaxrs.fortest.jaxb.SuperBook("CXF in Action",123L,124L); List books=Collections.singletonList(b); ByteArrayOutputStream bos=new ByteArrayOutputStream(); provider.writeTo(books,List.class,org.apache.cxf.jaxrs.fortest.jaxb.SuperBook.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),bos); String expected="" + "" + "123"+ "CXF in Action124"; assertEquals(expected,bos.toString()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testWriteWithXmlRootElementAndPackageInfo() throws Exception { JAXBElementProvider provider=new JAXBElementProvider(); Book2 book=new Book2(333); ByteArrayOutputStream bos=new ByteArrayOutputStream(); provider.writeTo(book,Book2.class,Book2.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),bos); assertTrue(bos.toString().contains("thebook2")); assertTrue(bos.toString().contains("http://superbooks")); ByteArrayInputStream is=new ByteArrayInputStream(bos.toByteArray()); Book2 book2=provider.readFrom(Book2.class,Book2.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),is); assertEquals(book2.getId(),book.getId()); }

EqualityVerifier 
@Test public void testOutElementsMapLocalNsToLocalWildcard2() throws Exception { JAXBElementProvider provider=new JAXBElementProvider(); Map prefixes=new HashMap(); prefixes.put("http://tags","ns2"); provider.setNamespacePrefixes(prefixes); Map map=new HashMap(); map.put("{http://tags}*","{http://tags2}*"); provider.setOutTransformElements(map); TagVO2 tag=new TagVO2("A","B"); TagVO2Holder holder=new TagVO2Holder(); holder.setTag(tag); ByteArrayOutputStream bos=new ByteArrayOutputStream(); provider.writeTo(holder,TagVO2Holder.class,TagVO2Holder.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),bos); String expected="" + "B" + "A"; assertEquals(expected,bos.toString()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testReadSuperBookWithJaxbElementAndTransform() throws Exception { final String data="" + "superbook111" + ""; JAXBElementProvider provider=new JAXBElementProvider(); provider.setUnmarshallAsJaxbElement(true); provider.setInTransformElements(Collections.singletonMap("{http://books}*","")); ByteArrayInputStream is=new ByteArrayInputStream(data.getBytes()); BookNoRootElement book=provider.readFrom(BookNoRootElement.class,BookNoRootElement.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),is); assertEquals(111L,book.getId()); assertEquals("superbook",book.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testReadSuperBookWithJaxbElement() throws Exception { final String data="" + "superbook111" + ""; JAXBElementProvider provider=new JAXBElementProvider(); provider.setUnmarshallAsJaxbElement(true); ByteArrayInputStream is=new ByteArrayInputStream(data.getBytes()); BookNoRootElement book=provider.readFrom(BookNoRootElement.class,BookNoRootElement.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),is); assertEquals(111L,book.getId()); assertEquals("superbook",book.getName()); }

EqualityVerifier 
@Test public void testOutElementsMapLocalToLocalNs() throws Exception { JAXBElementProvider provider=new JAXBElementProvider(); Map map=new HashMap(); map.put("tagVO","{http://tags}thetag"); provider.setOutTransformElements(map); TagVO tag=new TagVO("A","B"); ByteArrayOutputStream bos=new ByteArrayOutputStream(); provider.writeTo(tag,TagVO.class,TagVO.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),bos); String expected="" + "BA"; assertEquals(expected,bos.toString()); }

EqualityVerifier 
@Test public void testOutElementsMapLocalNsToLocal() throws Exception { JAXBElementProvider provider=new JAXBElementProvider(); Map map=new HashMap(); map.put("{http://tags}thetag","t"); provider.setOutTransformElements(map); TagVO2 tag=new TagVO2("A","B"); ByteArrayOutputStream bos=new ByteArrayOutputStream(); provider.writeTo(tag,TagVO2.class,TagVO2.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),bos); String expected="" + "BA"; assertEquals(expected,bos.toString()); }

EqualityVerifier 
@Test public void testOutElementsMapLocalNsToLocalNs() throws Exception { JAXBElementProvider provider=new JAXBElementProvider(); Map prefixes=new HashMap(); prefixes.put("http://tags","ns2"); provider.setNamespacePrefixes(prefixes); Map map=new HashMap(); map.put("{http://tags}thetag","{http://tagsvo2}t"); provider.setOutTransformElements(map); TagVO2 tag=new TagVO2("A","B"); ByteArrayOutputStream bos=new ByteArrayOutputStream(); provider.writeTo(tag,TagVO2.class,TagVO2.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),bos); String expected="" + "BA"; assertEquals(expected,bos.toString()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testInDropElement() throws Exception { String data="ba" + ""; JAXBElementProvider provider=new JAXBElementProvider(); provider.setInDropElements(Collections.singletonList("Extra")); ByteArrayInputStream is=new ByteArrayInputStream(data.getBytes()); Object o=provider.readFrom(ManyTags.class,ManyTags.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),is); ManyTags holder=(ManyTags)o; assertNotNull(holder); TagVO tag=holder.getTags().getTags().get(0); assertEquals("a",tag.getName()); assertEquals("b",tag.getGroup()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testReadFromISO() throws Exception { String eWithAcute="\u00E9"; String nameStringUTF16="F" + eWithAcute + "lix"; String bookStringUTF16="" + "" + nameStringUTF16 + ""; byte[] iso88591bytes=bookStringUTF16.getBytes("ISO-8859-1"); JAXBElementProvider p=new JAXBElementProvider(); Book book=p.readFrom(Book.class,null,new Annotation[]{},MediaType.valueOf(MediaType.APPLICATION_XML),null,new ByteArrayInputStream(iso88591bytes)); assertEquals(book.getName(),nameStringUTF16); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testInNsElementsFromLocalsWildcard2() throws Exception { String data="" + "B" + "A"; JAXBElementProvider provider=new JAXBElementProvider(); Map map=new LinkedHashMap(); map.put("group","group"); map.put("name","name"); map.put("{http://tags2}*","{http://tags}*"); provider.setInTransformElements(map); ByteArrayInputStream is=new ByteArrayInputStream(data.getBytes()); Object o=provider.readFrom(TagVO2Holder.class,TagVO2Holder.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),is); TagVO2Holder holder=(TagVO2Holder)o; TagVO2 tag2=holder.getTagValue(); assertEquals("A",tag2.getName()); assertEquals("B",tag2.getGroup()); }

EqualityVerifier 
@Test public void testOutElementsMapLocalToLocal() throws Exception { JAXBElementProvider provider=new JAXBElementProvider(); Map map=new HashMap(); map.put("tagVO","thetag"); map.put("group","group2"); provider.setOutTransformElements(map); TagVO tag=new TagVO("A","B"); ByteArrayOutputStream bos=new ByteArrayOutputStream(); provider.writeTo(tag,TagVO.class,TagVO.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),bos); String expected="" + "BA"; assertEquals(expected,bos.toString()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testReadChineeseChars() throws Exception { String nameStringUTF16="中文"; String bookStringUTF16="" + nameStringUTF16 + ""; JAXBElementProvider p=new JAXBElementProvider(); Book book=p.readFrom(Book.class,null,new Annotation[]{},MediaType.valueOf(MediaType.APPLICATION_XML + ";charset=UTF-8"),null,new ByteArrayInputStream(bookStringUTF16.getBytes(StandardCharsets.UTF_8))); assertEquals(book.getName(),nameStringUTF16); }

EqualityVerifier 
@Test public void testOutAttributesAsElements() throws Exception { JAXBElementProvider provider=new JAXBElementProvider(); Map map=new HashMap(); map.put("{http://tags}thetag","thetag"); map.put("{http://tags}tagholder","tagholder"); provider.setOutTransformElements(map); provider.setAttributesToElements(true); TagVO2 tag=new TagVO2("A","B"); TagVO2Holder holder=new TagVO2Holder(); holder.setTag(tag); ByteArrayOutputStream bos=new ByteArrayOutputStream(); provider.writeTo(holder,TagVO2Holder.class,TagVO2Holder.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),bos); String expected="attribute" + "BA"; assertEquals(expected,bos.toString()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testInNsElementsFromLocalsWildcard() throws Exception { String data="" + "BA"; JAXBElementProvider provider=new JAXBElementProvider(); Map map=new LinkedHashMap(); map.put("group","group"); map.put("name","name"); map.put("*","{http://tags}*"); provider.setInTransformElements(map); ByteArrayInputStream is=new ByteArrayInputStream(data.getBytes()); Object o=provider.readFrom(TagVO2Holder.class,TagVO2Holder.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),is); TagVO2Holder holder=(TagVO2Holder)o; TagVO2 tag2=holder.getTagValue(); assertEquals("A",tag2.getName()); assertEquals("B",tag2.getGroup()); }

APIUtilityVerifier IterativeVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGenericsAndSingleContext2() throws Exception { ClassResourceInfo cri=ResourceUtils.createClassResourceInfo(XmlListResource.class,XmlListResource.class,true,true); JAXBElementProvider provider=new JAXBElementProvider(); provider.setSingleJaxbContext(true); provider.init(Collections.singletonList(cri)); List list=new ArrayList(); for (int i=0; i < 10; i++) { org.apache.cxf.jaxrs.fortest.jaxb.SuperBook o=new org.apache.cxf.jaxrs.fortest.jaxb.SuperBook(); o.setName("name #" + i); list.add(o); } XmlList xmlList=new XmlList(list); Method m=XmlListResource.class.getMethod("testJaxb2",new Class[]{}); JAXBContext context=provider.getJAXBContext(m.getReturnType(),m.getGenericReturnType()); ByteArrayOutputStream os=new ByteArrayOutputStream(); context.createMarshaller().marshal(xmlList,os); @SuppressWarnings("unchecked") XmlList list2=(XmlList)context.createUnmarshaller().unmarshal(new ByteArrayInputStream(os.toByteArray())); List actualList=list2.getList(); assertEquals(10,actualList.size()); for (int i=0; i < 10; i++) { org.apache.cxf.jaxrs.fortest.jaxb.SuperBook object=actualList.get(i); assertEquals("name #" + i,object.getName()); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testExtraClassWithoutSingleContext() throws Exception { ClassResourceInfo cri=ResourceUtils.createClassResourceInfo(BookStore.class,BookStore.class,true,true); JAXBElementProvider provider=new JAXBElementProvider(); provider.setExtraClass(new Class[]{SuperBook.class}); provider.init(Collections.singletonList(cri)); JAXBContext bookContext=provider.getJAXBContext(Book.class,Book.class); ByteArrayOutputStream os=new ByteArrayOutputStream(); bookContext.createMarshaller().marshal(new SuperBook("name",1L,2L),os); SuperBook book=(SuperBook)bookContext.createUnmarshaller().unmarshal(new ByteArrayInputStream(os.toByteArray())); assertEquals(2L,book.getSuperId()); }

EqualityVerifier 
@Test public void testOutAppendElementsDiffNs() throws Exception { JAXBElementProvider provider=new JAXBElementProvider(); Map prefixes=new HashMap(); prefixes.put("http://tags","ns2"); provider.setNamespacePrefixes(prefixes); Map map=new HashMap(); map.put("{http://tags}thetag","{http://tagsvo2}t"); provider.setOutAppendElements(map); TagVO2 tag=new TagVO2("A","B"); ByteArrayOutputStream bos=new ByteArrayOutputStream(); provider.writeTo(tag,TagVO2.class,TagVO2.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),bos); String expected="" + "BA"; assertEquals(expected,bos.toString()); }

EqualityVerifier 
@Test public void testDropElements() throws Exception { JAXBElementProvider provider=new JAXBElementProvider(); List list=new ArrayList(); list.add("tagVO"); list.add("ManyTags"); list.add("list"); provider.setOutDropElements(list); ManyTags many=new ManyTags(); Tags tags=new Tags(); tags.addTag(new TagVO("A","B")); tags.addTag(new TagVO("C","D")); many.setTags(tags); ByteArrayOutputStream bos=new ByteArrayOutputStream(); provider.writeTo(many,ManyTags.class,ManyTags.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),bos); String expected="" + "BADC"; assertEquals(expected,bos.toString()); }

Class: org.apache.cxf.jaxrs.provider.PrimitiveTextProviderTest

InternalCallVerifier EqualityVerifier 
@SuppressWarnings("unchecked") @Test public void testReadByte() throws Exception { MessageBodyReader p=new PrimitiveTextProvider(); @SuppressWarnings("rawtypes") Byte valueRead=(Byte)p.readFrom((Class)Byte.TYPE,null,null,null,null,new ByteArrayInputStream("1".getBytes())); assertEquals(1,valueRead.byteValue()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testWriteStringISO() throws Exception { MessageBodyWriter p=new PrimitiveTextProvider(); ByteArrayOutputStream os=new ByteArrayOutputStream(); MultivaluedMap headers=new MetadataMap(); String eWithAcute="\u00E9"; String helloStringUTF16="Hello, my name is F" + eWithAcute + "lix Agn"+ eWithAcute+ "s"; p.writeTo(helloStringUTF16,String.class,String.class,null,MediaType.valueOf("text/plain;charset=ISO-8859-1"),headers,os); byte[] iso88591bytes=helloStringUTF16.getBytes("ISO-8859-1"); String helloStringISO88591=new String(iso88591bytes,"ISO-8859-1"); assertEquals(helloStringISO88591,os.toString("ISO-8859-1")); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testReadChineeseChars() throws Exception { String s="中文"; MessageBodyReader p=new PrimitiveTextProvider(); String value=(String)p.readFrom(String.class,null,new Annotation[]{},MediaType.valueOf(MediaType.APPLICATION_XML + ";charset=UTF-8"),null,new ByteArrayInputStream(s.getBytes(StandardCharsets.UTF_8))); assertEquals(value,value); }

Class: org.apache.cxf.jaxrs.provider.ProviderFactoryExceptionMapperTest

InternalCallVerifier EqualityVerifier 
@Test public void testNearestSuperclassMatch(){ ExceptionMapper exceptionMapper=pf.createExceptionMapper(NullPointerException.class,new MessageImpl()); assertEquals("Wrong mapper found for NullPointerException",RuntimeExceptionMapper.class,exceptionMapper.getClass()); }

InternalCallVerifier EqualityVerifier 
@Test public void testExactMatchInSecondPosition(){ ExceptionMapper exceptionMapper=pf.createExceptionMapper(RuntimeException1.class,new MessageImpl()); assertEquals("Wrong mapper found for RuntimeException1",RuntimeExceptionMapper1.class,exceptionMapper.getClass()); }

InternalCallVerifier EqualityVerifier 
@Test public void testExactMatchInFirstPosition(){ ExceptionMapper exceptionMapper=pf.createExceptionMapper(RuntimeException2.class,new MessageImpl()); assertEquals("Wrong mapper found for RuntimeException2",RuntimeExceptionMapper2.class,exceptionMapper.getClass()); }

Class: org.apache.cxf.jaxrs.provider.ProviderFactoryTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testCustomProviderSorting2(){ ProviderFactory pf=ServerProviderFactory.getInstance(); Comparator comp=new Comparator(){ @Override public int compare( Object provider1, Object provider2){ if (provider1 instanceof StringTextProvider) { return 1; } else if (provider2 instanceof StringTextProvider) { return -1; } else { return 0; } } } ; pf.setProviderComparator(comp); List>> writers=pf.getMessageWriters(); assertEquals(8,writers.size()); Object lastWriter=writers.get(7).getProvider(); assertTrue(lastWriter instanceof StringTextProvider); List>> readers=pf.getMessageReaders(); assertEquals(8,readers.size()); Object lastReader=readers.get(7).getProvider(); assertTrue(lastReader instanceof StringTextProvider); }

APIUtilityVerifier InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testCustomProviderSortingWithBus(){ WildcardReader wc1=new WildcardReader(); WildcardReader2 wc2=new WildcardReader2(); Bus bus=BusFactory.newInstance().createBus(); bus.setProperty(MessageBodyReader.class.getName(),wc1); ProviderFactory pf=ServerProviderFactory.createInstance(bus); pf.registerUserProvider(wc2); List>> readers=pf.getMessageReaders(); assertEquals(10,readers.size()); assertSame(wc2,readers.get(6).getProvider()); assertSame(wc1,readers.get(7).getProvider()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testCustomProviderSorting(){ ProviderFactory pf=ServerProviderFactory.getInstance(); Comparator comp=new Comparator>(){ @Override public int compare( ProviderInfo o1, ProviderInfo o2){ Object provider1=o1.getProvider(); Object provider2=o2.getProvider(); if (provider1 instanceof StringTextProvider) { return 1; } else if (provider2 instanceof StringTextProvider) { return -1; } else { return 0; } } } ; pf.setProviderComparator(comp); List>> writers=pf.getMessageWriters(); assertEquals(8,writers.size()); Object lastWriter=writers.get(7).getProvider(); assertTrue(lastWriter instanceof StringTextProvider); List>> readers=pf.getMessageReaders(); assertEquals(8,readers.size()); Object lastReader=readers.get(7).getProvider(); assertTrue(lastReader instanceof StringTextProvider); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@SuppressWarnings("rawtypes") @Test public void testCustomProviderSortingMBROnly(){ ProviderFactory pf=ServerProviderFactory.getInstance(); Comparator> comp=new Comparator>(){ @Override public int compare( ProviderInfo o1, ProviderInfo o2){ MessageBodyReader provider1=o1.getProvider(); MessageBodyReader provider2=o2.getProvider(); if (provider1 instanceof StringTextProvider) { return 1; } else if (provider2 instanceof StringTextProvider) { return -1; } else { return 0; } } } ; pf.setProviderComparator(comp); List>> writers=pf.getMessageWriters(); assertEquals(8,writers.size()); Object lastWriter=writers.get(7).getProvider(); assertFalse(lastWriter instanceof StringTextProvider); List>> readers=pf.getMessageReaders(); assertEquals(8,readers.size()); Object lastReader=readers.get(7).getProvider(); assertTrue(lastReader instanceof StringTextProvider); }

APIUtilityVerifier InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testCustomProviderSortingWithBus2(){ WildcardReader wc1=new WildcardReader(); WildcardReader2 wc2=new WildcardReader2(); Bus bus=BusFactory.newInstance().createBus(); bus.setProperty(MessageBodyReader.class.getName(),wc2); ProviderFactory pf=ServerProviderFactory.createInstance(bus); pf.registerUserProvider(wc1); List>> readers=pf.getMessageReaders(); assertEquals(10,readers.size()); assertSame(wc1,readers.get(6).getProvider()); assertSame(wc2,readers.get(7).getProvider()); }

InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testOrderOfProvidersWithSameProperties(){ ProviderFactory pf=ServerProviderFactory.getInstance(); WildcardReader reader1=new WildcardReader(); pf.registerUserProvider(reader1); WildcardReader2 reader2=new WildcardReader2(); pf.registerUserProvider(reader2); List>> readers=pf.getMessageReaders(); assertEquals(10,readers.size()); assertSame(reader1,readers.get(6).getProvider()); assertSame(reader2,readers.get(7).getProvider()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testCustomProviderSortingMBWOnly(){ ProviderFactory pf=ServerProviderFactory.getInstance(); Comparator>> comp=new Comparator>>(){ @Override public int compare( ProviderInfo> o1, ProviderInfo> o2){ MessageBodyWriter provider1=o1.getProvider(); MessageBodyWriter provider2=o2.getProvider(); if (provider1 instanceof StringTextProvider) { return 1; } else if (provider2 instanceof StringTextProvider) { return -1; } else { return 0; } } } ; pf.setProviderComparator(comp); List>> writers=pf.getMessageWriters(); assertEquals(8,writers.size()); Object lastWriter=writers.get(7).getProvider(); assertTrue(lastWriter instanceof StringTextProvider); List>> readers=pf.getMessageReaders(); assertEquals(8,readers.size()); Object lastReader=readers.get(7).getProvider(); assertFalse(lastReader instanceof StringTextProvider); }

Class: org.apache.cxf.jaxrs.provider.RequestDispatcherProviderTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testIsWriteableEnum2(){ RequestDispatcherProvider p=new RequestDispatcherProvider(); p.setEnumResources(Collections.singletonMap(TestEnum.ONE,"/test.jsp")); assertTrue(p.isWriteable(TestEnum.ONE.getClass(),null,null,null)); assertEquals("/test.jsp",p.getResourcePath(TestEnum.ONE.getClass(),TestEnum.ONE)); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testIsWriteableEnum(){ RequestDispatcherProvider p=new RequestDispatcherProvider(); p.setClassResources(Collections.singletonMap(TestEnum.class.getName() + "." + TestEnum.ONE,"/test.jsp")); assertTrue(p.isWriteable(TestEnum.ONE.getClass(),null,null,null)); assertEquals("/test.jsp",p.getResourcePath(TestEnum.ONE.getClass(),TestEnum.ONE)); }

Class: org.apache.cxf.jaxrs.provider.SourceProviderTest

APIUtilityVerifier EqualityVerifier 
@Test public void testWriteToDocument() throws Exception { SourceProvider p=new SourceProvider(); Document doc=StaxUtils.read(new StringReader("")); ByteArrayOutputStream os=new ByteArrayOutputStream(); p.writeTo(doc,Document.class,Document.class,new Annotation[]{},MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),os); String s=os.toString(); assertEquals("",s); }

Class: org.apache.cxf.jaxrs.provider.XPathProviderTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testReadFrom() throws Exception { String value="The Book2"; XPathProvider provider=new XPathProvider(); provider.setExpression("/Book"); provider.setClassName(Book.class.getName()); provider.setForceDOM(true); Book book=(Book)provider.readFrom(Book.class,null,null,null,null,new ByteArrayInputStream(value.getBytes())); assertNotNull(book); assertEquals(2L,book.getId()); assertEquals("The Book",book.getName()); }

Class: org.apache.cxf.jaxrs.provider.XSLTJaxbProviderTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testWriteWithoutTemplate() throws Exception { XSLTJaxbProvider provider=new XSLTJaxbProvider(); provider.setSupportJaxbOnly(true); Book b=new Book(); b.setId(123L); b.setName("TheBook"); ByteArrayOutputStream bos=new ByteArrayOutputStream(); provider.writeTo(b,Book.class,Book.class,b.getClass().getAnnotations(),MediaType.TEXT_XML_TYPE,new MetadataMap(),bos); Unmarshaller um=provider.getClassContext(Book.class).createUnmarshaller(); Book b2=(Book)um.unmarshal(new StringReader(bos.toString())); assertEquals(b,b2); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testReadWithoutTemplate() throws Exception { XSLTJaxbProvider provider=new XSLTJaxbProvider(); provider.setSupportJaxbOnly(true); Book b=new Book(); b.setId(123L); b.setName("TheBook"); Book b2=provider.readFrom(Book.class,Book.class,b.getClass().getAnnotations(),MediaType.TEXT_XML_TYPE,new MetadataMap(),new ByteArrayInputStream(BOOK_XML.getBytes())); assertEquals("Transformation is bad",b,b2); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testWrite() throws Exception { XSLTJaxbProvider provider=new XSLTJaxbProvider(); provider.setOutTemplate(TEMPLATE_LOCATION); provider.setMessageContext(new MessageContextImpl(createMessage())); Book b=new Book(); b.setId(123L); b.setName("TheBook"); ByteArrayOutputStream bos=new ByteArrayOutputStream(); provider.writeTo(b,Book.class,Book.class,b.getClass().getAnnotations(),MediaType.TEXT_XML_TYPE,new MetadataMap(),bos); Unmarshaller um=provider.getClassContext(Book.class).createUnmarshaller(); Book b2=(Book)um.unmarshal(new StringReader(bos.toString())); b.setName("TheBook2"); assertEquals("Transformation is bad",b,b2); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testWriteToStreamWriter() throws Exception { XSLTJaxbProvider provider=new XSLTJaxbProvider(){ @Override protected XMLStreamWriter getStreamWriter( Object obj, OutputStream os, MediaType mt){ return StaxUtils.createXMLStreamWriter(os); } } ; provider.setOutTemplate(TEMPLATE_LOCATION); provider.setMessageContext(new MessageContextImpl(createMessage())); Book b=new Book(); b.setId(123L); b.setName("TheBook"); ByteArrayOutputStream bos=new ByteArrayOutputStream(); provider.writeTo(b,Book.class,Book.class,b.getClass().getAnnotations(),MediaType.TEXT_XML_TYPE,new MetadataMap(),bos); Unmarshaller um=provider.getClassContext(Book.class).createUnmarshaller(); Book b2=(Book)um.unmarshal(new StringReader(bos.toString())); b.setName("TheBook2"); assertEquals("Transformation is bad",b,b2); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testRead() throws Exception { XSLTJaxbProvider provider=new XSLTJaxbProvider(); provider.setInTemplate(TEMPLATE_LOCATION); Book b=new Book(); b.setId(123L); b.setName("TheBook"); Book b2=provider.readFrom(Book.class,Book.class,b.getClass().getAnnotations(),MediaType.TEXT_XML_TYPE,new MetadataMap(),new ByteArrayInputStream(BOOK_XML.getBytes())); b.setName("TheBook2"); assertEquals("Transformation is bad",b,b2); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testReadFromStreamReader() throws Exception { XSLTJaxbProvider provider=new XSLTJaxbProvider(){ @Override protected XMLStreamReader getStreamReader( InputStream is, Class type, MediaType mt){ return StaxUtils.createXMLStreamReader(is); } } ; provider.setInTemplate(TEMPLATE_LOCATION); Book b=new Book(); b.setId(123L); b.setName("TheBook"); Book b2=provider.readFrom(Book.class,Book.class,b.getClass().getAnnotations(),MediaType.TEXT_XML_TYPE,new MetadataMap(),new ByteArrayInputStream(BOOK_XML.getBytes())); b.setName("TheBook2"); assertEquals("Transformation is bad",b,b2); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testWriteWithAnnotation() throws Exception { XSLTJaxbProvider provider=new XSLTJaxbProvider(); provider.setMessageContext(new MessageContextImpl(createMessage())); Book b=new Book(); b.setId(123L); b.setName("TheBook"); ByteArrayOutputStream bos=new ByteArrayOutputStream(); Annotation[] anns=Root.class.getMethod("getBook").getAnnotations(); assertTrue(provider.isWriteable(Book.class,Book.class,anns,MediaType.TEXT_XML_TYPE)); provider.writeTo(b,Book.class,Book.class,anns,MediaType.TEXT_XML_TYPE,new MetadataMap(),bos); Unmarshaller um=provider.getClassContext(Book.class).createUnmarshaller(); Book b2=(Book)um.unmarshal(new StringReader(bos.toString())); b.setName("TheBook2"); assertEquals("Transformation is bad",b,b2); }

Class: org.apache.cxf.jaxrs.provider.aegis.AegisElementProviderTest

APIUtilityVerifier EqualityVerifier 
@Test public void testNoNamespaceWriteTo() throws Exception { MessageBodyWriter p=new NoNamespaceAegisElementProvider(); ByteArrayOutputStream os=new ByteArrayOutputStream(); AegisTestBean bean=new AegisTestBean(); bean.setBoolValue(Boolean.TRUE); bean.setStrValue("hovercraft"); p.writeTo(bean,null,null,new Annotation[]{},MediaType.APPLICATION_OCTET_STREAM_TYPE,new MetadataMap(),os); byte[] bytes=os.toByteArray(); String xml=new String(bytes,"utf-8"); assertEquals(noNamespaceXml,xml); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testNoNamespaceReadFrom() throws Exception { MessageBodyReader p=new NoNamespaceAegisElementProvider(); byte[] bytes=noNamespaceXml.getBytes("utf-8"); AegisTestBean bean=p.readFrom(AegisTestBean.class,null,null,null,null,new ByteArrayInputStream(bytes)); assertEquals("hovercraft",bean.getStrValue()); assertEquals(Boolean.TRUE,bean.getBoolValue()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testReadFrom() throws Exception { MessageBodyReader p=new AegisElementProvider(); byte[] simpleBytes=simpleBeanXml.getBytes("utf-8"); AegisTestBean bean=p.readFrom(AegisTestBean.class,null,null,null,null,new ByteArrayInputStream(simpleBytes)); assertEquals("hovercraft",bean.getStrValue()); assertEquals(Boolean.TRUE,bean.getBoolValue()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testWriteTo() throws Exception { MessageBodyWriter p=new AegisElementProvider(); ByteArrayOutputStream os=new ByteArrayOutputStream(); AegisTestBean bean=new AegisTestBean(); bean.setBoolValue(Boolean.TRUE); bean.setStrValue("hovercraft"); p.writeTo(bean,null,null,new Annotation[]{},MediaType.APPLICATION_OCTET_STREAM_TYPE,new MetadataMap(),os); byte[] bytes=os.toByteArray(); String xml=new String(bytes,"utf-8"); assertEquals(simpleBeanXml,xml); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testReadWriteComplexMap() throws Exception { Map testMap=new HashMap(); Class iwithMapClass=InterfaceWithMap.class; Method method=iwithMapClass.getMethod("mapFunction"); Type mapType=method.getGenericReturnType(); AegisTestBean bean=new AegisTestBean(); bean.setBoolValue(Boolean.TRUE); bean.setStrValue("hovercraft"); AegisSuperBean bean2=new AegisSuperBean(); bean2.setBoolValue(Boolean.TRUE); bean2.setStrValue("hovercraft2"); testMap.put(bean,bean2); MessageBodyWriter> writer=new AegisElementProvider>(); ByteArrayOutputStream os=new ByteArrayOutputStream(); writer.writeTo(testMap,testMap.getClass(),mapType,new Annotation[]{},MediaType.APPLICATION_OCTET_STREAM_TYPE,new MetadataMap(),os); byte[] bytes=os.toByteArray(); String xml=new String(bytes,"utf-8"); MessageBodyReader> reader=new AegisElementProvider>(); byte[] simpleBytes=xml.getBytes("utf-8"); Map map2=reader.readFrom(null,mapType,new Annotation[]{},MediaType.APPLICATION_OCTET_STREAM_TYPE,new MetadataMap(),new ByteArrayInputStream(simpleBytes)); assertEquals(1,map2.size()); Map.Entry entry=map2.entrySet().iterator().next(); AegisTestBean bean1=entry.getKey(); assertEquals("hovercraft",bean1.getStrValue()); assertEquals(Boolean.TRUE,bean1.getBoolValue()); AegisTestBean bean22=entry.getValue(); assertEquals("hovercraft2",bean22.getStrValue()); assertEquals(Boolean.TRUE,bean22.getBoolValue()); }

Class: org.apache.cxf.jaxrs.provider.aegis.AegisJSONProviderTest

EqualityVerifier 
@Test public void testWriteCollectionNoXsiType() throws Exception { String json=writeCollection(false,false,null,true,false); assertEquals("{\"ns1.ArrayOfAegisTestBean\":{" + "\"ns1.AegisTestBean\":[{\"ns1.boolValue\":true," + "\"ns1.strValue\":\"hovercraft\"},{"+ "\"ns1.boolValue\":true,\"ns1.strValue\":\"hovercraft2\"}]}}",json); }

EqualityVerifier 
@Test public void testWriteCollectionNoXsiTypeSingleBeanArrayKey() throws Exception { String json=writeCollection(false,false,"AegisTestBean",false,true); assertEquals("{\"ArrayOfAegisTestBean\":{" + "\"AegisTestBean\":[{\"boolValue\":true,\"strValue\":\"hovercraft\"}" + "]}}",json); }

EqualityVerifier 
@Test public void testWriteCollectionNoXsiTypeDropRootElement() throws Exception { String json=writeCollection(false,true,null,true,false); assertEquals("{" + "\"ns1.AegisTestBean\":[{\"ns1.boolValue\":true," + "\"ns1.strValue\":\"hovercraft\"},{"+ "\"ns1.boolValue\":true,\"ns1.strValue\":\"hovercraft2\"}]}",json); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testReadCollection() throws Exception { String json=writeCollection(true,false,null,true,false); byte[] simpleBytes=json.getBytes("utf-8"); Method m=CollectionsResource.class.getMethod("getAegisBeans",new Class[]{}); AegisJSONProvider> p=new AegisJSONProvider>(); List list=p.readFrom(null,m.getGenericReturnType(),null,null,null,new ByteArrayInputStream(simpleBytes)); assertEquals(2,list.size()); AegisTestBean bean=list.get(0); assertEquals("hovercraft",bean.getStrValue()); assertEquals(Boolean.TRUE,bean.getBoolValue()); bean=list.get(1); assertEquals("hovercraft2",bean.getStrValue()); assertEquals(Boolean.TRUE,bean.getBoolValue()); }

EqualityVerifier 
@Test public void testWriteCollectionNoXsiTypeSingleBean() throws Exception { String json=writeCollection(false,false,null,false,false); assertEquals("{\"ns1.ArrayOfAegisTestBean\":{" + "\"ns1.AegisTestBean\":{\"ns1.boolValue\":true,\"ns1.strValue\":\"hovercraft\"}" + "}}",json); }

EqualityVerifier 
@Test public void testWriteCollectionNoXsiTypeArrayKey() throws Exception { String json=writeCollection(false,false,"ns1.AegisTestBean",true,false); assertEquals("{\"ns1.ArrayOfAegisTestBean\":{" + "\"ns1.AegisTestBean\":[{\"ns1.boolValue\":true,\"ns1.strValue\":\"hovercraft\"}," + "{\"ns1.boolValue\":true,\"ns1.strValue\":\"hovercraft2\"}]}}",json); }

EqualityVerifier 
@Test public void testWriteCollection() throws Exception { String json=writeCollection(true,false,null,true,false); assertEquals("{\"ns1.ArrayOfAegisTestBean\":{\"@xsi.type\":\"ns1:ArrayOfAegisTestBean\"," + "\"ns1.AegisTestBean\":[{\"@xsi.type\":\"ns1:AegisTestBean\",\"ns1.boolValue\":true," + "\"ns1.strValue\":\"hovercraft\"},{\"@xsi.type\":\"ns1:AegisTestBean\","+ "\"ns1.boolValue\":true,\"ns1.strValue\":\"hovercraft2\"}]}}",json); }

EqualityVerifier 
@Test public void testWriteCollectionIgnoreNs() throws Exception { String json=writeCollection(false,false,"ns1.AegisTestBean",true,true); assertEquals("{\"ArrayOfAegisTestBean\":{" + "\"AegisTestBean\":[{\"boolValue\":true,\"strValue\":\"hovercraft\"}," + "{\"boolValue\":true,\"strValue\":\"hovercraft2\"}]}}",json); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@org.junit.Ignore @Test public void testReadWriteComplexMap() throws Exception { Map testMap=new HashMap(); Class iwithMapClass=InterfaceWithMap.class; Method method=iwithMapClass.getMethod("mapFunction"); Type mapType=method.getGenericReturnType(); AegisTestBean bean=new AegisTestBean(); bean.setBoolValue(Boolean.TRUE); bean.setStrValue("hovercraft"); AegisSuperBean bean2=new AegisSuperBean(); bean2.setBoolValue(Boolean.TRUE); bean2.setStrValue("hovercraft2"); testMap.put(bean,bean2); AegisJSONProvider> writer=new AegisJSONProvider>(); ByteArrayOutputStream os=new ByteArrayOutputStream(); writer.writeTo(testMap,testMap.getClass(),mapType,null,null,null,os); byte[] bytes=os.toByteArray(); String xml=new String(bytes,"utf-8"); String expected=properties.getProperty("testReadWriteComplexMap.expected"); assertEquals(expected,xml); AegisJSONProvider> reader=new AegisJSONProvider>(); byte[] simpleBytes=xml.getBytes("utf-8"); Map map2=reader.readFrom(null,mapType,null,null,null,new ByteArrayInputStream(simpleBytes)); assertEquals(1,map2.size()); Map.Entry entry=map2.entrySet().iterator().next(); AegisTestBean bean1=entry.getKey(); assertEquals("hovercraft",bean1.getStrValue()); assertEquals(Boolean.TRUE,bean1.getBoolValue()); AegisTestBean bean22=entry.getValue(); assertEquals("hovercraft2",bean22.getStrValue()); assertEquals(Boolean.TRUE,bean22.getBoolValue()); }

Class: org.apache.cxf.jaxrs.provider.atom.AtomEntryProviderTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testAnnotations(){ String[] values=afd.getClass().getAnnotation(Produces.class).value(); assertEquals("3 types can be produced",3,values.length); assertTrue("application/atom+xml".equals(values[0]) && "application/atom+xml;type=entry".equals(values[1]) && "application/json".equals(values[2])); values=afd.getClass().getAnnotation(Consumes.class).value(); assertEquals("2 types can be consumed",2,values.length); assertTrue("application/atom+xml".equals(values[0]) && "application/atom+xml;type=entry".equals(values[1])); }

InternalCallVerifier EqualityVerifier 
@Test public void testReadFrom() throws Exception { InputStream is=getClass().getResourceAsStream("atomEntry.xml"); Entry simple=afd.readFrom(Entry.class,null,null,null,null,is); assertEquals("Wrong entry title","Atom-Powered Robots Run Amok",simple.getTitle()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testWriteTo() throws Exception { InputStream is=getClass().getResourceAsStream("atomEntry.xml"); Entry simple=afd.readFrom(Entry.class,null,null,MediaType.valueOf("application/atom+xml;type=entry"),null,is); ByteArrayOutputStream bos=new ByteArrayOutputStream(); afd.writeTo(simple,null,null,null,MediaType.valueOf("application/atom+xml;type=entry"),null,bos); ByteArrayInputStream bis=new ByteArrayInputStream(bos.toByteArray()); Entry simpleCopy=afd.readFrom(Entry.class,null,null,MediaType.valueOf("application/atom+xml"),null,bis); assertEquals("Wrong entry title","Atom-Powered Robots Run Amok",simpleCopy.getTitle()); assertEquals("Wrong entry title",simple.getTitle(),simpleCopy.getTitle()); }

Class: org.apache.cxf.jaxrs.provider.atom.AtomFeedProviderTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testAnnotations(){ String[] values=afd.getClass().getAnnotation(Produces.class).value(); assertEquals("3 types can be produced",3,values.length); assertTrue("application/atom+xml".equals(values[0]) && "application/atom+xml;type=feed".equals(values[1]) && "application/json".equals(values[2])); values=afd.getClass().getAnnotation(Consumes.class).value(); assertEquals("2 types can be consumed",2,values.length); assertTrue("application/atom+xml".equals(values[0]) && "application/atom+xml;type=feed".equals(values[1])); }

InternalCallVerifier EqualityVerifier 
@Test public void testReadFrom() throws Exception { InputStream is=getClass().getResourceAsStream("atomFeed.xml"); Feed simple=afd.readFrom(Feed.class,null,null,null,null,is); assertEquals("Wrong feed title","Example Feed",simple.getTitle()); }

Class: org.apache.cxf.jaxrs.provider.atom.AtomPojoProviderTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testWriteFeedWithBuildersNoJaxb() throws Exception { AtomPojoProvider provider=(AtomPojoProvider)ctx.getBean("atomNoJaxb"); assertNotNull(provider); provider.setFormattedOutput(true); ByteArrayOutputStream bos=new ByteArrayOutputStream(); Books books=new Books(); List bs=new ArrayList(); bs.add(new Book("a")); bs.add(new Book("b")); books.setBooks(bs); provider.writeTo(books,Books.class,Books.class,new Annotation[]{},MediaType.valueOf("application/atom+xml"),null,bos); ByteArrayInputStream bis=new ByteArrayInputStream(bos.toByteArray()); Feed feed=new AtomFeedProvider().readFrom(Feed.class,null,null,null,null,bis); assertEquals("Books",feed.getTitle()); List entries=feed.getEntries(); assertEquals(2,entries.size()); Entry entryA=getEntry(entries,"a"); verifyEntry(entryA,"a"); String entryAContent=entryA.getContent(); assertTrue("".equals(entryAContent) || "".equals(entryAContent) || "".equals(entryAContent)); Entry entryB=getEntry(entries,"b"); verifyEntry(entryB,"b"); String entryBContent=entryB.getContent(); assertTrue("".equals(entryBContent) || "".equals(entryBContent) || "".equals(entryBContent)); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testWriteFeedWithBuilders() throws Exception { AtomPojoProvider provider=(AtomPojoProvider)ctx.getBean("atom"); assertNotNull(provider); provider.setFormattedOutput(true); ByteArrayOutputStream bos=new ByteArrayOutputStream(); Books books=new Books(); List bs=new ArrayList(); bs.add(new Book("a")); bs.add(new Book("b")); books.setBooks(bs); provider.writeTo(books,Books.class,Books.class,new Annotation[]{},MediaType.valueOf("application/atom+xml"),null,bos); ByteArrayInputStream bis=new ByteArrayInputStream(bos.toByteArray()); Feed feed=new AtomFeedProvider().readFrom(Feed.class,null,null,null,null,bis); assertEquals("Books",feed.getTitle()); List entries=feed.getEntries(); assertEquals(2,entries.size()); verifyEntry(getEntry(entries,"a"),"a"); verifyEntry(getEntry(entries,"b"),"b"); }

Class: org.apache.cxf.jaxrs.provider.dom4j.DOM4JProviderTest

APIUtilityVerifier EqualityVerifier 
@Test public void testWriteJSONAsArray() throws Exception { org.dom4j.Document dom=readXML(MediaType.APPLICATION_XML_TYPE,"
1"); DOM4JProvider p=new DOM4JProvider(); ProviderFactory factory=ServerProviderFactory.getInstance(); JSONProvider provider=new JSONProvider(); provider.setSerializeAsArray(true); provider.setDropRootElement(true); provider.setDropElementsInXmlStream(false); provider.setIgnoreNamespaces(true); factory.registerUserProvider(provider); p.setProviders(new ProvidersImpl(createMessage(factory))); ByteArrayOutputStream bos=new ByteArrayOutputStream(); p.writeTo(dom,org.dom4j.Document.class,org.dom4j.Document.class,new Annotation[]{},MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),bos); String str=bos.toString(); assertEquals("[{\"a\":1}]",str); }

APIUtilityVerifier EqualityVerifier 
@Test public void testWriteJSON() throws Exception { org.dom4j.Document dom=readXML(); DOM4JProvider p=new DOM4JProvider(); p.setProviders(new ProvidersImpl(createMessage(false))); ByteArrayOutputStream bos=new ByteArrayOutputStream(); p.writeTo(dom,org.dom4j.Document.class,org.dom4j.Document.class,new Annotation[]{},MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),bos); String str=bos.toString(); assertEquals("{\"a\":\"\"}",str); }

APIUtilityVerifier EqualityVerifier 
@Test public void testWriteJSONDropRoot() throws Exception { org.dom4j.Document dom=readXML(MediaType.APPLICATION_XML_TYPE,""); DOM4JProvider p=new DOM4JProvider(); p.setProviders(new ProvidersImpl(createMessageWithJSONProvider())); ByteArrayOutputStream bos=new ByteArrayOutputStream(); p.writeTo(dom,org.dom4j.Document.class,org.dom4j.Document.class,new Annotation[]{},MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),bos); String str=bos.toString(); assertEquals("{\"a\":\"\"}",str); }

Class: org.apache.cxf.jaxrs.provider.json.DataBindingJSONProviderTest

EqualityVerifier 
@Test public void testJAXBWrite() throws Exception { Service s=new JAXRSServiceImpl(Collections.singletonList(c),true); DataBinding binding=new JAXBDataBinding(); binding.initialize(s); DataBindingJSONProvider p=new DataBindingJSONProvider(); p.setDataBinding(binding); Book b=new Book("CXF",127L); ByteArrayOutputStream bos=new ByteArrayOutputStream(); p.writeTo(b,Book.class,Book.class,new Annotation[0],MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),bos); String data="{\"Book\":{\"id\":127,\"name\":\"CXF\",\"state\":\"\"}}"; assertEquals(bos.toString(),data); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testJAXBRead() throws Exception { String data="{\"Book\":{\"id\":127,\"name\":\"CXF\",\"state\":\"\"}}"; Service s=new JAXRSServiceImpl(Collections.singletonList(c),true); DataBinding binding=new JAXBDataBinding(); binding.initialize(s); DataBindingJSONProvider p=new DataBindingJSONProvider(); p.setDataBinding(binding); ByteArrayInputStream is=new ByteArrayInputStream(data.getBytes()); Book book=(Book)p.readFrom(Book.class,Book.class,new Annotation[0],MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),is); assertEquals("CXF",book.getName()); assertEquals(127L,book.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testSDORead() throws Exception { String data="{\"p0.Structure\":{\"@xsi.type\":\"p0:Structure\",\"p0.text\":\"sdo\",\"p0.int\":3" + ",\"p0.dbl\":123.5,\"p0.texts\":\"text1\"}}"; Service s=new JAXRSServiceImpl(Collections.singletonList(c2),true); DataBinding binding=new SDODataBinding(); binding.initialize(s); DataBindingJSONProvider p=new DataBindingJSONProvider(); p.setDataBinding(binding); p.setNamespaceMap(Collections.singletonMap("http://apache.org/structure/types","p0")); ByteArrayInputStream is=new ByteArrayInputStream(data.getBytes()); Structure struct=p.readFrom(Structure.class,Structure.class,new Annotation[0],MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),is); assertEquals("sdo",struct.getText()); assertEquals(123.5,struct.getDbl(),0.01); assertEquals(3,struct.getInt()); }

EqualityVerifier 
@SuppressWarnings("unchecked") @Test public void testSDOWrite() throws Exception { Service s=new JAXRSServiceImpl(Collections.singletonList(c2),true); DataBinding binding=new SDODataBinding(); binding.initialize(s); DataBindingJSONProvider p=new DataBindingJSONProvider(); p.setDataBinding(binding); p.setNamespaceMap(Collections.singletonMap("http://apache.org/structure/types","p0")); Structure struct=new StructureImpl(); struct.getTexts().add("text1"); struct.setText("sdo"); struct.setInt(3); struct.setDbl(123.5); ByteArrayOutputStream bos=new ByteArrayOutputStream(); p.writeTo(struct,Structure.class,Structure.class,new Annotation[0],MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),bos); String data="{\"p0.Structure\":{\"@xsi.type\":\"p0:Structure\",\"p0.text\":\"sdo\",\"p0.int\":3" + ",\"p0.dbl\":123.5,\"p0.texts\":\"text1\"}}"; assertEquals(bos.toString(),data); }

Class: org.apache.cxf.jaxrs.provider.json.JSONProviderTest

EqualityVerifier 
@Test public void testDropQualifiedElements() throws Exception { JSONProvider provider=new JSONProvider(); List list=new ArrayList(); list.add("{http://tags}thetag"); provider.setOutDropElements(list); Map map=new HashMap(); map.put("name",""); provider.setOutTransformElements(map); TagVO2 tag=new TagVO2("A","B"); ByteArrayOutputStream bos=new ByteArrayOutputStream(); provider.writeTo(tag,TagVO2.class,TagVO2.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),bos); String expected="{\"group\":\"B\"}"; assertEquals(expected,bos.toString()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testWriteToListWithManyValues() throws Exception { JSONProvider p=new JSONProvider(); Tags tags=new Tags(); tags.addTag(createTag("a","b")); tags.addTag(createTag("c","d")); ByteArrayOutputStream os=new ByteArrayOutputStream(); p.writeTo(tags,Tags.class,Tags.class,Tags.class.getAnnotations(),MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),os); String s=os.toString(); assertEquals("{\"Tags\":{\"list\":[{\"group\":\"b\",\"name\":\"a\"},{\"group\":\"d\",\"name\":\"c\"}]}}",s); }

EqualityVerifier 
@Test public void testOutAppendLocalBeforeLocal() throws Exception { JSONProvider provider=new JSONProvider(); Map map=new HashMap(); map.put("tagVO","supertag"); provider.setOutAppendElements(map); TagVO tag=new TagVO("A","B"); ByteArrayOutputStream bos=new ByteArrayOutputStream(); provider.writeTo(tag,TagVO.class,TagVO.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),bos); String expected="{\"supertag\":{\"tagVO\":{\"group\":\"B\",\"name\":\"A\"}}}"; assertEquals(expected,bos.toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testReadFromUnwrappedQualifiedTagRoot() throws Exception { JSONProvider p=new JSONProvider(); p.setSupportUnwrapped(true); Map namespaceMap=new HashMap(); namespaceMap.put("http://tags","ns1"); p.setNamespaceMap(namespaceMap); byte[] bytes="{\"group\":\"b\",\"name\":\"a\"}".getBytes(); Object tagsObject=p.readFrom(TagVO2.class,null,null,null,null,new ByteArrayInputStream(bytes)); TagVO2 tag=(TagVO2)tagsObject; assertEquals("a",tag.getName()); assertEquals("b",tag.getGroup()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testWriteArrayAndNamespaceOnObject() throws Exception { JSONProvider p=new JSONProvider(); p.setIgnoreNamespaces(true); p.setSerializeAsArray(true); TagVO2 tag=new TagVO2("a","b"); ByteArrayOutputStream os=new ByteArrayOutputStream(); p.writeTo(tag,TagVO2.class,TagVO2.class,TagVO2.class.getAnnotations(),MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),os); String s=os.toString(); assertEquals("{\"thetag\":[{\"group\":\"b\",\"name\":\"a\"}]}",s); }

APIUtilityVerifier EqualityVerifier 
@Test public void testWriteBookWithStringConverter() throws Exception { JSONProvider p=new JSONProvider(); p.setConvertTypesToStrings(true); Book book=new Book("CXF",125); ByteArrayOutputStream os=new ByteArrayOutputStream(); p.writeTo(book,Book.class,Book.class,Book.class.getAnnotations(),MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),os); String s=os.toString(); assertEquals("{\"Book\":{\"id\":\"125\",\"name\":\"CXF\",\"state\":\"\"}}",s); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testReadListOfDerivedTypesWithNullField() throws Exception { JSONProvider p=new JSONProvider(); Map namespaceMap=new HashMap(); namespaceMap.put("http://www.w3.org/2001/XMLSchema-instance","xsins"); p.setNamespaceMap(namespaceMap); String data="{\"books2\":{\"books\":{\"@xsins.type\":\"superBook\",\"id\":123," + "\"name\":null,\"superId\":124}}}"; byte[] bytes=data.getBytes(); Object books2Object=p.readFrom(Books2.class,null,null,null,null,new ByteArrayInputStream(bytes)); Books2 books=(Books2)books2Object; List list=books.getBooks(); assertEquals(1,list.size()); SuperBook book=(SuperBook)list.get(0); assertEquals(124L,book.getSuperId()); assertEquals(0,book.getName().length()); }

EqualityVerifier 
@Test public void testOutElementsMapLocalToLocalNs() throws Exception { JSONProvider provider=new JSONProvider(); Map namespaceMap=new HashMap(); namespaceMap.put("http://tags","ns1"); Map map=new HashMap(); map.put("tagVO","{http://tags}thetag"); provider.setOutTransformElements(map); TagVO tag=new TagVO("A","B"); ByteArrayOutputStream bos=new ByteArrayOutputStream(); provider.writeTo(tag,TagVO.class,TagVO.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),bos); String expected="{\"ps1.thetag\":{\"group\":\"B\",\"name\":\"A\"}}"; assertEquals(expected,bos.toString()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testReadEmbeddedArrayWithNamespaces() throws Exception { String input="{\"ns1.store\":" + "{\"ns1.books\":{" + " \"ns1.thebook2\":["+ " { "+ " \"name\":\"CXF 1\""+ " }, "+ " { "+ " \"name\":\"CXF 2\""+ " } "+ " ] "+ " } "+ " } "+ "} "; JSONProvider p=new JSONProvider(); Map namespaceMap=new HashMap(); namespaceMap.put("http://superbooks","ns1"); p.setNamespaceMap(namespaceMap); Object storeObject=p.readFrom(QualifiedStore.class,null,null,null,null,new ByteArrayInputStream(input.getBytes())); QualifiedStore store=(QualifiedStore)storeObject; List books=store.getBooks(); assertEquals(2,books.size()); assertEquals("CXF 1",books.get(0).getName()); assertEquals("CXF 2",books.get(1).getName()); }

InternalCallVerifier EqualityVerifier 
@Test public void testReadFromTag() throws Exception { MessageBodyReader p=new JSONProvider(); byte[] bytes="{\"tagVO\":{\"group\":\"b\",\"name\":\"a\"}}".getBytes(); Object tagsObject=p.readFrom(TagVO.class,null,null,null,null,new ByteArrayInputStream(bytes)); TagVO tag=(TagVO)tagsObject; assertEquals("a",tag.getName()); assertEquals("b",tag.getGroup()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testManyTags() throws Exception { JSONProvider p=new JSONProvider(); p.setSerializeAsArray(true); p.setArrayKeys(Collections.singletonList("list")); Tags tags=new Tags(); tags.addTag(createTag("a","b")); ManyTags many=new ManyTags(); many.setTags(tags); ByteArrayOutputStream os=new ByteArrayOutputStream(); p.writeTo(many,ManyTags.class,ManyTags.class,ManyTags.class.getAnnotations(),MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),os); String s=os.toString(); assertEquals("{\"ManyTags\":{\"tags\":{\"list\":[{\"group\":\"b\",\"name\":\"a\"}]}}}",s); }

APIUtilityVerifier EqualityVerifier ExceptionVerifier HybridVerifier 
@Test(expected=BadRequestException.class) public void testIgnoreNamespacesPackageInfo() throws Exception { JSONProvider p=new JSONProvider(); p.setIgnoreNamespaces(true); Book2 book=new Book2(123); book.setName("CXF"); ByteArrayOutputStream os=new ByteArrayOutputStream(); p.writeTo(book,Book2.class,Book2.class,Book2.class.getAnnotations(),MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),os); String s=os.toString(); assertEquals("{\"thebook2\":{\"id\":123,\"name\":\"CXF\"}}",s); p.readFrom(Book2.class,null,Book2.class.getAnnotations(),MediaType.APPLICATION_JSON_TYPE,null,new ByteArrayInputStream(s.getBytes())); }

APIUtilityVerifier EqualityVerifier 
@Test public void testDropRootElementFromDocument() throws Exception { JSONProvider p=new JSONProvider(); Document doc=StaxUtils.read(new StringReader("
2")); p.setDropRootElement(true); ByteArrayOutputStream os=new ByteArrayOutputStream(); p.writeTo(doc,Document.class,Document.class,new Annotation[]{},MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),os); String s=os.toString(); assertEquals("{\"b\":2}",s); }

APIUtilityVerifier EqualityVerifier 
@Test public void testWriteToSingleQualifiedTag2() throws Exception { JSONProvider p=new JSONProvider(); p.setNamespaceMap(Collections.singletonMap("http://tags","ns1")); TagVO2 tag=createTag2("a","b"); ByteArrayOutputStream os=new ByteArrayOutputStream(); p.writeTo(tag,TagVO2.class,TagVO2.class,TagVO2.class.getAnnotations(),MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),os); String s=os.toString(); assertEquals("{\"ns1.thetag\":{\"group\":\"b\",\"name\":\"a\"}}",s); }

EqualityVerifier 
@Test public void testWriteCollectionWithoutXmlRootElement() throws Exception { JSONProvider> provider=new JSONProvider>(); provider.setCollectionWrapperName("{http://superbooks}SuperBooks"); provider.setJaxbElementClassMap(Collections.singletonMap(SuperBook.class.getName(),"{http://superbooks}SuperBook")); SuperBook b=new SuperBook("CXF in Action",123L,124L); List books=Collections.singletonList(b); ByteArrayOutputStream bos=new ByteArrayOutputStream(); provider.writeTo(books,List.class,SuperBook.class,new Annotation[0],MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),bos); String expected="{\"ns1.SuperBooks\":[{\"id\":123,\"name\":\"CXF in Action\"," + "\"state\":\"\",\"superId\":124}]}"; assertEquals(expected,bos.toString()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testWriteToSingleTagBadgerFish() throws Exception { JSONProvider p=new JSONProvider(); p.setConvention("badgerfish"); TagVO tag=createTag("a","b"); ByteArrayOutputStream os=new ByteArrayOutputStream(); p.writeTo(tag,TagVO.class,TagVO.class,TagVO.class.getAnnotations(),MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),os); String s=os.toString(); assertEquals("{\"tagVO\":{\"group\":{\"$\":\"b\"},\"name\":{\"$\":\"a\"}}}",s); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testReadMalformedJson() throws Exception { MessageBodyReader p=new JSONProvider(); byte[] bytes="junk".getBytes(); try { p.readFrom(Tags.class,null,null,null,null,new ByteArrayInputStream(bytes)); fail("404 is expected"); } catch ( WebApplicationException ex) { assertEquals(Response.Status.BAD_REQUEST.getStatusCode(),ex.getResponse().getStatus()); } }

APIUtilityVerifier EqualityVerifier 
@Test public void testDropRootElement() throws Exception { JSONProvider p=new JSONProvider(); p.setDropRootElement(true); p.setIgnoreNamespaces(true); Map namespaceMap=new HashMap(); namespaceMap.put("http://tags","ns1"); p.setNamespaceMap(namespaceMap); TagVO2 tag=createTag2("a","b"); ByteArrayOutputStream os=new ByteArrayOutputStream(); p.writeTo(tag,TagVO2.class,TagVO2.class,TagVO2.class.getAnnotations(),MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),os); String s=os.toString(); assertEquals("{\"group\":\"b\",\"name\":\"a\"}",s); }

EqualityVerifier 
@Test public void testDropElements() throws Exception { JSONProvider provider=new JSONProvider(); List list=new ArrayList(); list.add("ManyTags"); list.add("tags"); provider.setOutDropElements(list); ManyTags many=new ManyTags(); Tags tags=new Tags(); tags.addTag(new TagVO("A","B")); tags.addTag(new TagVO("C","D")); many.setTags(tags); ByteArrayOutputStream bos=new ByteArrayOutputStream(); provider.writeTo(many,ManyTags.class,ManyTags.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),bos); String expected="{\"list\":[{\"group\":\"B\",\"name\":\"A\"}," + "{\"group\":\"D\",\"name\":\"C\"}]}"; assertEquals(expected,bos.toString()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testWriteListOfDerivedTypes() throws Exception { JSONProvider p=new JSONProvider(); Map namespaceMap=new HashMap(); namespaceMap.put("http://www.w3.org/2001/XMLSchema-instance","xsins"); p.setNamespaceMap(namespaceMap); Books2 books2=new Books2(); books2.setBooks(Collections.singletonList(new SuperBook("CXF Rocks",123L,124L))); ByteArrayOutputStream os=new ByteArrayOutputStream(); p.writeTo(books2,Books2.class,Books2.class,Books2.class.getAnnotations(),MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),os); String s=os.toString(); String data="{\"books2\":{\"books\":{\"@xsins.type\":\"superBook\",\"id\":123," + "\"name\":\"CXF Rocks\",\"state\":\"\",\"superId\":124}}}"; assertEquals(data,s); }

EqualityVerifier 
@Test public void testWriteUnqualifiedCollection() throws Exception { JSONProvider> p=new JSONProvider>(); List books=new ArrayList(); books.add(new Book("CXF",123L)); ByteArrayOutputStream os=new ByteArrayOutputStream(); Method m=CollectionsResource.class.getMethod("getBooks",new Class[0]); p.writeTo(books,m.getReturnType(),m.getGenericReturnType(),new Annotation[0],MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),os); assertEquals("{\"Book\":[{\"id\":123,\"name\":\"CXF\",\"state\":\"\"}]}",os.toString()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testManyTagsEmptyArray() throws Exception { JSONProvider p=new JSONProvider(){ protected XMLStreamWriter createWriter( Object actualObject, Class actualClass, Type genericType, String enc, OutputStream os, boolean isCollection) throws Exception { return new EmptyListWriter(super.createWriter(actualObject,actualClass,genericType,enc,os,isCollection)); } } ; p.setSerializeAsArray(true); p.setArrayKeys(Collections.singletonList("list")); p.setIgnoreEmptyArrayValues(true); Tags tags=new Tags(); tags.addTag(createTag("a","b")); ManyTags many=new ManyTags(); many.setTags(tags); ByteArrayOutputStream os=new ByteArrayOutputStream(); p.writeTo(many,ManyTags.class,ManyTags.class,ManyTags.class.getAnnotations(),MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),os); String s=os.toString(); assertEquals("{\"ManyTags\":{\"tags\":{\"list\":[]}}}",s); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testReadListOfDerivedTypes() throws Exception { JSONProvider p=new JSONProvider(); Map namespaceMap=new HashMap(); namespaceMap.put("http://www.w3.org/2001/XMLSchema-instance","xsins"); p.setNamespaceMap(namespaceMap); String data="{\"books2\":{\"books\":{\"@xsins.type\":\"superBook\",\"id\":123," + "\"name\":\"CXF Rocks\",\"superId\":124}}}"; byte[] bytes=data.getBytes(); Object books2Object=p.readFrom(Books2.class,null,null,null,null,new ByteArrayInputStream(bytes)); Books2 books=(Books2)books2Object; List list=books.getBooks(); assertEquals(1,list.size()); SuperBook book=(SuperBook)list.get(0); assertEquals(124L,book.getSuperId()); assertEquals(123L,book.getId()); assertEquals("CXF Rocks",book.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testInNsElementsFromLocals() throws Exception { String data="{tagholder:{thetag:{\"group\":\"B\",\"name\":\"A\"}}}"; JSONProvider provider=new JSONProvider(); Map map=new HashMap(); map.put("tagholder","{http://tags}tagholder"); map.put("thetag","{http://tags}thetag"); provider.setInTransformElements(map); ByteArrayInputStream is=new ByteArrayInputStream(data.getBytes()); Object o=provider.readFrom(TagVO2Holder.class,TagVO2Holder.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),is); TagVO2Holder holder=(TagVO2Holder)o; TagVO2 tag2=holder.getTagValue(); assertEquals("A",tag2.getName()); assertEquals("B",tag2.getGroup()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testWriteToListWithSingleValue() throws Exception { JSONProvider p=new JSONProvider(); p.setSerializeAsArray(true); p.setArrayKeys(Collections.singletonList("list")); Tags tags=new Tags(); tags.addTag(createTag("a","b")); ByteArrayOutputStream os=new ByteArrayOutputStream(); p.writeTo(tags,Tags.class,Tags.class,Tags.class.getAnnotations(),MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),os); String s=os.toString(); assertEquals("{\"Tags\":{\"list\":[{\"group\":\"b\",\"name\":\"a\"}]}}",s); }

APIUtilityVerifier EqualityVerifier 
@Test public void testWriteToSingleTag() throws Exception { JSONProvider p=new JSONProvider(); TagVO tag=createTag("a","b"); ByteArrayOutputStream os=new ByteArrayOutputStream(); p.writeTo(tag,TagVO.class,TagVO.class,TagVO.class.getAnnotations(),MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),os); String s=os.toString(); assertEquals("{\"tagVO\":{\"group\":\"b\",\"name\":\"a\"}}",s); }

APIUtilityVerifier EqualityVerifier 
@Test public void testIgnoreNamespacesPackageInfo2() throws Exception { JSONProvider p=new JSONProvider(); p.setMarshallAsJaxbElement(true); p.setIgnoreNamespaces(true); Book2NoRootElement book=new Book2NoRootElement(123); ByteArrayOutputStream os=new ByteArrayOutputStream(); p.writeTo(book,Book2NoRootElement.class,Book2NoRootElement.class,Book2NoRootElement.class.getAnnotations(),MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),os); String s=os.toString(); assertEquals("{\"book2\":{\"id\":123}}",s); }

EqualityVerifier 
@Test public void testOutAppendElementsSameNs() throws Exception { JSONProvider provider=new JSONProvider(); Map namespaceMap=new HashMap(); namespaceMap.put("http://tags","ns2"); provider.setNamespaceMap(namespaceMap); Map map=new HashMap(); map.put("{http://tags}thetag","{http://tags}t"); provider.setOutAppendElements(map); TagVO2 tag=new TagVO2("A","B"); ByteArrayOutputStream bos=new ByteArrayOutputStream(); provider.writeTo(tag,TagVO2.class,TagVO2.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),bos); String expected="{\"ns2.t\":{\"ns2.thetag\":{\"group\":\"B\",\"name\":\"A\"}}}"; assertEquals(expected,bos.toString()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testReadListOfProperties() throws Exception { String input="{\"theBook\":" + "{" + "\"Names\":[{\"Name\":\"1\"}, {\"Name\":\"2\"}]"+ " } "+ "} "; JSONProvider provider=new JSONProvider(); provider.setPrimitiveArrayKeys(Collections.singletonList("Names")); TheBook theBook=provider.readFrom(TheBook.class,null,null,null,null,new ByteArrayInputStream(input.getBytes())); List names=theBook.getName(); assertNotNull(names); assertEquals("1",names.get(0)); assertEquals("2",names.get(1)); }

EqualityVerifier 
@Test public void testOutElementsMapLocalToLocal() throws Exception { JSONProvider provider=new JSONProvider(); Map map=new HashMap(); map.put("tagVO","supertag"); map.put("group","group2"); provider.setOutTransformElements(map); TagVO tag=new TagVO("A","B"); ByteArrayOutputStream bos=new ByteArrayOutputStream(); provider.writeTo(tag,TagVO.class,TagVO.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),bos); String expected="{\"supertag\":{\"group2\":\"B\",\"name\":\"A\"}}"; assertEquals(expected,bos.toString()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testIgnoreNamespaces() throws Exception { JSONProvider p=new JSONProvider(); p.setIgnoreNamespaces(true); TestBean bean=new TestBean(); bean.setName("a"); bean.setId("b"); ByteArrayOutputStream os=new ByteArrayOutputStream(); p.writeTo(bean,TestBean.class,TestBean.class,new Annotation[0],MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),os); String s=os.toString(); assertEquals("{\"testBean\":{\"@id\":\"b\",\"name\":\"a\"}}",s); }

EqualityVerifier 
@Test public void testOutAppendNsElementBeforeLocal() throws Exception { JSONProvider provider=new JSONProvider(); Map map=new HashMap(); map.put("tagVO","{http://tagsvo2}t"); provider.setOutAppendElements(map); TagVO tag=new TagVO("A","B"); ByteArrayOutputStream bos=new ByteArrayOutputStream(); provider.writeTo(tag,TagVO.class,TagVO.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),bos); String expected="{\"ps1.t\":{\"tagVO\":{\"group\":\"B\",\"name\":\"A\"}}}"; assertEquals(expected,bos.toString()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testWriteDocumentToWriter() throws Exception { TagVO tag=createTag("a","b"); ByteArrayOutputStream os=new ByteArrayOutputStream(); new JAXBElementProvider().writeTo(tag,TagVO.class,TagVO.class,TagVO.class.getAnnotations(),MediaType.APPLICATION_XML_TYPE,new MetadataMap(),os); Document doc=StaxUtils.read(new StringReader(os.toString())); ByteArrayOutputStream os2=new ByteArrayOutputStream(); new JSONProvider().writeTo(doc,Document.class,Document.class,new Annotation[]{},MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),os2); String s=os2.toString(); assertEquals("{\"tagVO\":{\"group\":\"b\",\"name\":\"a\"}}",s); }

InternalCallVerifier EqualityVerifier 
@Test public void testReadFromTags() throws Exception { MessageBodyReader p=new JSONProvider(); byte[] bytes="{\"Tags\":{\"list\":[{\"group\":\"b\",\"name\":\"a\"},{\"group\":\"d\",\"name\":\"c\"}]}}".getBytes(); Object tagsObject=p.readFrom(Tags.class,null,null,null,null,new ByteArrayInputStream(bytes)); Tags tags=(Tags)tagsObject; List list=tags.getTags(); assertEquals(2,list.size()); assertEquals("a",list.get(0).getName()); assertEquals("b",list.get(0).getGroup()); assertEquals("c",list.get(1).getName()); assertEquals("d",list.get(1).getGroup()); }

EqualityVerifier 
@Test public void testOutAttributesAsElementsForList() throws Exception { JSONProvider> provider=new JSONProvider>(); provider.setCollectionWrapperName("tagholders"); Map map=new HashMap(); map.put("{http://tags}*","*"); provider.setOutTransformElements(map); provider.setAttributesToElements(true); TagVO2 tag=new TagVO2("A","B"); TagVO2Holder holder=new TagVO2Holder(); holder.setTag(tag); List list=new ArrayList(); list.add(holder); ParameterizedType type=new ParameterizedType(){ public Type getRawType(){ return List.class; } public Type getOwnerType(){ return null; } public Type[] getActualTypeArguments(){ return new Type[]{TagVO2Holder.class}; } } ; ByteArrayOutputStream bos=new ByteArrayOutputStream(); provider.writeTo(list,ArrayList.class,type,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),bos); String expected="{\"tagholders\":[" + "{\"attr\":\"attribute\",\"thetag\":{\"group\":\"B\",\"name\":\"A\"}}" + "]}"; assertEquals(expected,bos.toString()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testReadNullStringAsNull() throws Exception { String input="{\"Book\":{\"id\":123,\"name\":\"null\"}}"; JSONProvider provider=new JSONProvider(); Book theBook=provider.readFrom(Book.class,null,null,null,null,new ByteArrayInputStream(input.getBytes())); assertEquals(123L,theBook.getId()); assertEquals("",theBook.getName()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testWriteToSingleQualifiedTagBadgerFish() throws Exception { JSONProvider p=new JSONProvider(); Map namespaceMap=new HashMap(); namespaceMap.put("http://tags","ns2"); p.setNamespaceMap(namespaceMap); p.setConvention("badgerfish"); TagVO2 tag=createTag2("a","b"); ByteArrayOutputStream os=new ByteArrayOutputStream(); p.writeTo(tag,TagVO2.class,TagVO2.class,TagVO2.class.getAnnotations(),MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),os); String s=os.toString(); assertEquals("{\"ns2:thetag\":{\"@xmlns\":{\"ns2\":\"http:\\/\\/tags\"}," + "\"group\":{\"$\":\"b\"},\"name\":{\"$\":\"a\"}}}",s); }

APIUtilityVerifier EqualityVerifier 
@Test public void testWriteUsingNaturalNotation() throws Exception { JSONProvider p=new JSONProvider(); p.setSerializeAsArray(true); p.setArrayKeys(Collections.singletonList("comments")); Post post=new Post(); post.setTitle("post"); Comment c1=new Comment(); c1.setTitle("comment1"); Comment c2=new Comment(); c2.setTitle("comment2"); post.getComments().add(c1); post.getComments().add(c2); ByteArrayOutputStream os=new ByteArrayOutputStream(); p.writeTo(post,Post.class,Post.class,Post.class.getAnnotations(),MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),os); String s=os.toString(); assertEquals("{\"post\":{\"title\":\"post\",\"comments\":[{\"title\":\"comment1\"}," + "{\"title\":\"comment2\"}]}}",s); }

EqualityVerifier 
@Test public void testWriteWithXmlRootElementAndPackageInfo() throws Exception { JSONProvider provider=new JSONProvider(); org.apache.cxf.jaxrs.resources.jaxb.Book2 book=new org.apache.cxf.jaxrs.resources.jaxb.Book2(333); ByteArrayOutputStream bos=new ByteArrayOutputStream(); provider.writeTo(book,org.apache.cxf.jaxrs.resources.jaxb.Book2.class,org.apache.cxf.jaxrs.resources.jaxb.Book2.class,new Annotation[0],MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),bos); assertEquals("{\"os.thebook2\":{\"id\":333}}",bos.toString()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testReadEmbeddedArray() throws Exception { String input="{\"store\":" + "{\"books\":{" + " \"book\":["+ " { "+ " \"name\":\"CXF 1\""+ " }, "+ " { "+ " \"name\":\"CXF 2\""+ " } "+ " ] "+ " } "+ " } "+ "} "; Object storeObject=new JSONProvider().readFrom(Store.class,null,null,null,null,new ByteArrayInputStream(input.getBytes())); Store store=(Store)storeObject; List books=store.getBooks(); assertEquals(2,books.size()); assertEquals("CXF 1",books.get(0).getName()); assertEquals("CXF 2",books.get(1).getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testInDropElement() throws Exception { String data="{\"Extra\":{\"ManyTags\":{\"tags\":{\"list\":[{\"group\":\"b\",\"name\":\"a\"}]}}}}"; JSONProvider provider=new JSONProvider(); provider.setInDropElements(Collections.singletonList("Extra")); ByteArrayInputStream is=new ByteArrayInputStream(data.getBytes()); Object o=provider.readFrom(ManyTags.class,ManyTags.class,new Annotation[0],MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),is); ManyTags holder=(ManyTags)o; assertNotNull(holder); TagVO tag=holder.getTags().getTags().get(0); assertEquals("a",tag.getName()); assertEquals("b",tag.getGroup()); }

EqualityVerifier 
@Test public void testOutAppendElementsDiffNs() throws Exception { JSONProvider provider=new JSONProvider(); Map namespaceMap=new HashMap(); namespaceMap.put("http://tags","ns2"); provider.setNamespaceMap(namespaceMap); Map map=new HashMap(); map.put("{http://tags}thetag","{http://tagsvo2}t"); provider.setOutAppendElements(map); TagVO2 tag=new TagVO2("A","B"); ByteArrayOutputStream bos=new ByteArrayOutputStream(); provider.writeTo(tag,TagVO2.class,TagVO2.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),bos); String expected="{\"ps1.t\":{\"ns2.thetag\":{\"group\":\"B\",\"name\":\"A\"}}}"; assertEquals(expected,bos.toString()); }

EqualityVerifier 
@Test public void testOutAttributesAsElements() throws Exception { JSONProvider provider=new JSONProvider(); Map map=new HashMap(); map.put("{http://tags}thetag","thetag"); map.put("{http://tags}tagholder","tagholder"); provider.setOutTransformElements(map); provider.setAttributesToElements(true); TagVO2 tag=new TagVO2("A","B"); TagVO2Holder holder=new TagVO2Holder(); holder.setTag(tag); ByteArrayOutputStream bos=new ByteArrayOutputStream(); provider.writeTo(holder,TagVO2Holder.class,TagVO2Holder.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),bos); String expected="{\"tagholder\":{\"attr\":\"attribute\",\"thetag\":{\"group\":\"B\",\"name\":\"A\"}}}"; assertEquals(expected,bos.toString()); }

EqualityVerifier 
@Test public void testOutElementsMapLocalNsToLocalNs() throws Exception { JSONProvider provider=new JSONProvider(); Map namespaceMap=new HashMap(); namespaceMap.put("http://tags","ns2"); provider.setNamespaceMap(namespaceMap); Map map=new HashMap(); map.put("{http://tags}thetag","{http://tagsvo2}t"); provider.setOutTransformElements(map); TagVO2 tag=new TagVO2("A","B"); ByteArrayOutputStream bos=new ByteArrayOutputStream(); provider.writeTo(tag,TagVO2.class,TagVO2.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),bos); String expected="{\"ns2.t\":{\"group\":\"B\",\"name\":\"A\"}}"; assertEquals(expected,bos.toString()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testWriteToSingleTag2NoNs() throws Exception { JSONProvider p=new JSONProvider(); p.setIgnoreNamespaces(true); TagVO2 tag=createTag2("a","b"); ByteArrayOutputStream os=new ByteArrayOutputStream(); p.writeTo(tag,TagVO2.class,TagVO2.class,TagVO2.class.getAnnotations(),MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),os); String s=os.toString(); assertEquals("{\"thetag\":{\"group\":\"b\",\"name\":\"a\"}}",s); }

EqualityVerifier 
@Test public void testOutElementsMapLocalNsToLocal() throws Exception { JSONProvider provider=new JSONProvider(); Map map=new HashMap(); map.put("{http://tags}thetag","t"); provider.setOutTransformElements(map); TagVO2 tag=new TagVO2("A","B"); ByteArrayOutputStream bos=new ByteArrayOutputStream(); provider.writeTo(tag,TagVO2.class,TagVO2.class,new Annotation[0],MediaType.TEXT_XML_TYPE,new MetadataMap(),bos); String expected="{\"t\":{\"group\":\"B\",\"name\":\"A\"}}"; assertEquals(expected,bos.toString()); }

Class: org.apache.cxf.jaxrs.provider.jsonp.JsonpInterceptorTest

EqualityVerifier 
@Test public void testJsonWithDefaultPadding() throws Exception { Message message=new MessageImpl(); message.put(Message.ACCEPT_CONTENT_TYPE,JsonpInInterceptor.JSONP_TYPE); message.setExchange(new ExchangeImpl()); ByteArrayOutputStream bos=new ByteArrayOutputStream(); message.setContent(OutputStream.class,bos); in.handleMessage(message); preStream.handleMessage(message); postStream.handleMessage(message); assertEquals("callback();",bos.toString()); }

EqualityVerifier 
@Test public void testJsonWithPadding() throws Exception { Message message=new MessageImpl(); message.put(Message.CONTENT_TYPE,MediaType.APPLICATION_JSON); message.setExchange(new ExchangeImpl()); message.put(Message.QUERY_STRING,JsonpInInterceptor.CALLBACK_PARAM + "=" + "myCallback"); ByteArrayOutputStream bos=new ByteArrayOutputStream(); message.setContent(OutputStream.class,bos); in.handleMessage(message); preStream.handleMessage(message); postStream.handleMessage(message); assertEquals("myCallback();",bos.toString()); }

EqualityVerifier 
@Test public void testJsonWithPaddingCustomCallbackParam() throws Exception { Message message=new MessageImpl(); message.put(Message.CONTENT_TYPE,MediaType.APPLICATION_JSON); message.setExchange(new ExchangeImpl()); message.put(Message.QUERY_STRING,"_customjsonp=myCallback"); ByteArrayOutputStream bos=new ByteArrayOutputStream(); message.setContent(OutputStream.class,bos); try { in.setCallbackParam("_customjsonp"); in.handleMessage(message); preStream.handleMessage(message); postStream.handleMessage(message); assertEquals("myCallback();",bos.toString()); } finally { in.setCallbackParam("_jsonp"); } }

EqualityVerifier 
@Test public void testJsonWithoutPadding() throws Exception { Message message=new MessageImpl(); message.put(Message.CONTENT_TYPE,MediaType.APPLICATION_JSON); message.setExchange(new ExchangeImpl()); ByteArrayOutputStream bos=new ByteArrayOutputStream(); message.setContent(OutputStream.class,bos); in.handleMessage(message); preStream.handleMessage(message); postStream.handleMessage(message); assertEquals("",bos.toString()); }

Class: org.apache.cxf.jaxrs.security.JAASAuthenticationFilterTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testRFC2617() throws Exception { JAASAuthenticationFilter filter=new JAASAuthenticationFilter(); filter.setRealmName("foo"); Message m=new MessageImpl(); Response r=filter.handleAuthenticationException(new SecurityException("Bad Auth"),m); assertNotNull(r); String result=r.getHeaderString(HttpHeaders.WWW_AUTHENTICATE); assertNotNull(result); assertEquals("Basic realm=\"foo\"",result); }

Class: org.apache.cxf.jaxrs.servlet.AbstractSciTest

InternalCallVerifier EqualityVerifier 
@Test public void testResponseHasBeenReceivedWhenQueringBook(){ Response r=createWebClient("/bookstore/books").path("1").get(); assertEquals(Status.OK.getStatusCode(),r.getStatus()); Book book=r.readEntity(Book.class); assertEquals("1",book.getId()); }

Class: org.apache.cxf.jaxrs.spring.JAXRSServerFactoryBeanTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testServers() throws Exception { ClassPathXmlApplicationContext ctx=new ClassPathXmlApplicationContext(new String[]{"/org/apache/cxf/jaxrs/spring/servers.xml"}); JAXRSServerFactoryBean sfb=(JAXRSServerFactoryBean)ctx.getBean("simple"); assertEquals("Get a wrong address","http://localhost:9090/rs",sfb.getAddress()); assertNotNull("The resource classes should not be null",sfb.getResourceClasses()); assertEquals("Get a wrong resource class",BookStore.class,sfb.getResourceClasses().get(0)); QName serviceQName=new QName("http://books.com","BookService"); assertEquals(serviceQName,sfb.getServiceName()); assertEquals(serviceQName,sfb.getServiceFactory().getServiceName()); sfb=(JAXRSServerFactoryBean)ctx.getBean("inlineServiceBeans"); assertNotNull("The resource classes should not be null",sfb.getResourceClasses()); assertEquals("Get a wrong resource class",BookStore.class,sfb.getResourceClasses().get(0)); assertEquals("Get a wrong resource class",BookStoreSubresourcesOnly.class,sfb.getResourceClasses().get(1)); sfb=(JAXRSServerFactoryBean)ctx.getBean("inlineProvider"); assertNotNull("The provider should not be null",sfb.getProviders()); assertEquals("Get a wrong provider size",2,sfb.getProviders().size()); verifyJaxbProvider(sfb.getProviders()); sfb=(JAXRSServerFactoryBean)ctx.getBean("moduleServer"); assertNotNull("The resource classes should not be null",sfb.getResourceClasses()); assertEquals("Get a wrong ResourceClasses size",1,sfb.getResourceClasses().size()); assertEquals("Get a wrong resource class",BookStoreNoAnnotations.class,sfb.getResourceClasses().get(0)); ctx.close(); }

Class: org.apache.cxf.jaxrs.spring.SpringResourceFactoryTest

InternalCallVerifier IdentityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testFactory() throws Exception { ClassPathXmlApplicationContext ctx=new ClassPathXmlApplicationContext(new String[]{"/org/apache/cxf/jaxrs/spring/servers2.xml"}); verifyFactory(ctx,"sfactory1",true); verifyFactory(ctx,"sfactory2",false); Object serverBean=ctx.getBean("server1"); assertNotNull(serverBean); JAXRSServerFactoryBean factoryBean=(JAXRSServerFactoryBean)serverBean; List list=factoryBean.getServiceFactory().getClassResourceInfo(); assertNotNull(list); assertEquals(4,list.size()); assertSame(BookStoreConstructor.class,list.get(0).getServiceClass()); assertSame(BookStoreConstructor.class,list.get(0).getResourceClass()); assertSame(BookStore.class,list.get(1).getServiceClass()); assertSame(BookStore.class,list.get(1).getResourceClass()); }

Class: org.apache.cxf.jaxrs.swagger.Swagger2FeatureTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSetBasePathByAddress(){ Swagger2Feature f=new Swagger2Feature(); f.setBasePathByAddress("http://localhost:8080/foo"); assertEquals("/foo",f.getBasePath()); assertEquals("localhost:8080",f.getHost()); unsetBasePath(f); f.setBasePathByAddress("http://localhost/foo"); assertEquals("/foo",f.getBasePath()); assertEquals("localhost",f.getHost()); unsetBasePath(f); f.setBasePathByAddress("/foo"); assertEquals("/foo",f.getBasePath()); assertNull(f.getHost()); unsetBasePath(f); }

Class: org.apache.cxf.jaxrs.swagger.SwaggerFeatureTest

InternalCallVerifier EqualityVerifier 
@Test public void testSetBasePathByAddress(){ SwaggerFeature f=new SwaggerFeature(); f.setBasePathByAddress("http://localhost:8080/foo"); assertEquals("http://localhost:8080/foo",f.getBasePath()); unsetBasePath(f); f.setBasePathByAddress("/foo"); assertEquals("/foo",f.getBasePath()); unsetBasePath(f); }

Class: org.apache.cxf.jaxrs.swagger.SwaggerUtilsTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testConvertSwagger20ToUserResource(){ UserResource ur=SwaggerUtils.getUserResource("/swagger20.json"); assertNotNull(ur); assertEquals("/base",ur.getPath()); assertEquals(1,ur.getOperations().size()); UserOperation op=ur.getOperations().get(0); assertEquals("postOp",op.getName()); assertEquals("/somepath",op.getPath()); assertEquals("POST",op.getVerb()); assertEquals("application/x-www-form-urlencoded",op.getConsumes()); assertEquals("application/json",op.getProduces()); assertEquals(3,op.getParameters().size()); Parameter param1=op.getParameters().get(0); assertEquals("userName",param1.getName()); assertEquals(ParameterType.FORM,param1.getType()); assertEquals(String.class,param1.getJavaType()); Parameter param2=op.getParameters().get(1); assertEquals("password",param2.getName()); assertEquals(ParameterType.FORM,param2.getType()); assertEquals(String.class,param2.getJavaType()); Parameter param3=op.getParameters().get(2); assertEquals("type",param3.getName()); assertEquals(ParameterType.MATRIX,param3.getType()); assertEquals(String.class,param3.getJavaType()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testConvertSwagger12ToUserResource(){ UserResource ur=SwaggerUtils.getUserResource("/swagger12.json"); assertNotNull(ur); assertEquals("/hello",ur.getPath()); assertEquals(1,ur.getOperations().size()); UserOperation op=ur.getOperations().get(0); assertEquals("helloSubject",op.getName()); assertEquals("/{subject}",op.getPath()); assertEquals("GET",op.getVerb()); assertEquals(1,op.getParameters().size()); Parameter param=op.getParameters().get(0); assertEquals("subject",param.getName()); assertEquals(ParameterType.PATH,param.getType()); assertEquals(String.class,param.getJavaType()); }

Class: org.apache.cxf.jaxrs.utils.AnnotationTestUtilsTest

APIUtilityVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testGetAnnotatedMethodFromClass() throws Exception { Method m=Customer.class.getMethod("getContextResolver",new Class[]{}); assertEquals(0,m.getAnnotations().length); Method annotatedMethod=AnnotationUtils.getAnnotatedMethod(Customer.class,m); assertSame(m,annotatedMethod); }

APIUtilityVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testGetAnnotatedMethodFromInterface() throws Exception { Method m=Customer.class.getMethod("setUriInfoContext",new Class[]{UriInfo.class}); assertEquals(0,m.getAnnotations().length); assertEquals(0,m.getParameterAnnotations()[0].length); Method annotatedMethod=AnnotationUtils.getAnnotatedMethod(Customer.class,m); assertNotSame(m,annotatedMethod); assertEquals(1,annotatedMethod.getParameterAnnotations()[0].length); }

EqualityVerifier 
@Test public void testCustomHttpMethodValue() throws Exception { Method m=ResourceClass.class.getMethod("update",new Class[]{}); assertEquals("UPDATE",AnnotationUtils.getHttpMethodValue(m)); }

Class: org.apache.cxf.jaxrs.utils.FormUtilsTest

InternalCallVerifier EqualityVerifier 
@Test public void populateMapFromStringFromHTTP(){ mockObjects(null); EasyMock.replay(mockMessage,mockRequest); MultivaluedMap params=new MetadataMap(); FormUtils.populateMapFromString(params,mockMessage,null,StandardCharsets.UTF_8.name(),false,mockRequest); assertEquals(2,params.size()); assertEquals(HTTP_PARAM_VALUE1,params.get(HTTP_PARAM1).iterator().next()); assertEquals(HTTP_PARAM_VALUE2,params.get(HTTP_PARAM2).iterator().next()); }

InternalCallVerifier EqualityVerifier 
@Test public void populateMapFromStringFromBody(){ mockObjects(null); EasyMock.replay(mockMessage,mockRequest); MultivaluedMap params=new MetadataMap(); String postBody=FORM_PARAM1 + "=" + FORM_PARAM_VALUE1+ "&"+ FORM_PARAM2+ "="+ FORM_PARAM_VALUE2; FormUtils.populateMapFromString(params,mockMessage,postBody,StandardCharsets.UTF_8.name(),false,mockRequest); assertEquals(2,params.size()); assertEquals(FORM_PARAM_VALUE1,params.get(FORM_PARAM1).iterator().next()); assertEquals(FORM_PARAM_VALUE2,params.get(FORM_PARAM2).iterator().next()); }

Class: org.apache.cxf.jaxrs.utils.HttpUtilsTest

EqualityVerifier 
@Test public void testParameterErrorStatus(){ assertEquals(Response.Status.NOT_FOUND,HttpUtils.getParameterFailureStatus(ParameterType.PATH)); assertEquals(Response.Status.NOT_FOUND,HttpUtils.getParameterFailureStatus(ParameterType.QUERY)); assertEquals(Response.Status.NOT_FOUND,HttpUtils.getParameterFailureStatus(ParameterType.MATRIX)); assertEquals(Response.Status.BAD_REQUEST,HttpUtils.getParameterFailureStatus(ParameterType.HEADER)); assertEquals(Response.Status.BAD_REQUEST,HttpUtils.getParameterFailureStatus(ParameterType.FORM)); assertEquals(Response.Status.BAD_REQUEST,HttpUtils.getParameterFailureStatus(ParameterType.COOKIE)); }

EqualityVerifier 
@Test public void testCommaInQuery(){ assertEquals("a+,b",HttpUtils.queryEncode("a ,b")); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testReplaceAnyIPAddress(){ Message m=new MessageImpl(); HttpServletRequest req=EasyMock.createMock(HttpServletRequest.class); m.put(AbstractHTTPDestination.HTTP_REQUEST,req); req.getScheme(); EasyMock.expectLastCall().andReturn("http"); req.getServerName(); EasyMock.expectLastCall().andReturn("localhost"); req.getServerPort(); EasyMock.expectLastCall().andReturn(8080); EasyMock.replay(req); URI u=HttpUtils.toAbsoluteUri(URI.create("http://0.0.0.0/bar/foo"),m); assertEquals("http://localhost:8080/bar/foo",u.toString()); }

EqualityVerifier 
@Test public void testUrlDecode(){ assertEquals("+ ",HttpUtils.urlDecode("%2B+")); }

EqualityVerifier 
@Test public void testUrlDecodeReserved(){ assertEquals("!$&'()*,;=",HttpUtils.urlDecode("!$&'()*,;=")); }

EqualityVerifier 
@Test public void testUrlEncode(){ assertEquals("%2B+",HttpUtils.urlEncode("+ ")); }

EqualityVerifier 
@Test public void testPathToMatch(){ assertEquals("/",HttpUtils.getPathToMatch("/","/",true)); assertEquals("/",HttpUtils.getPathToMatch("/","/bar",true)); assertEquals("/",HttpUtils.getPathToMatch("/bar","/bar/",true)); assertEquals("/bar",HttpUtils.getPathToMatch("/bar","/",true)); assertEquals("/",HttpUtils.getPathToMatch("/bar","/bar",true)); assertEquals("/bar",HttpUtils.getPathToMatch("/baz/bar","/baz",true)); assertEquals("/baz/bar/foo/",HttpUtils.getPathToMatch("/baz/bar/foo/","/bar",true)); }

EqualityVerifier 
@Test public void testPathEncodeWithPlusAndSpace(){ assertEquals("+%20",HttpUtils.pathEncode("+ ")); }

APIUtilityVerifier EqualityVerifier 
@Test public void testPathEncode(){ String pathChars=":@!$&'()*+,;=-._~"; String str=HttpUtils.pathEncode(pathChars); assertEquals(str,pathChars); }

InternalCallVerifier EqualityVerifier 
@Test public void testUpdatePath(){ Message m=new MessageImpl(); m.setExchange(new ExchangeImpl()); m.put(Message.ENDPOINT_ADDRESS,"http://localhost/"); HttpUtils.updatePath(m,"/bar"); assertEquals("/bar",m.get(Message.REQUEST_URI)); HttpUtils.updatePath(m,"bar"); assertEquals("/bar",m.get(Message.REQUEST_URI)); HttpUtils.updatePath(m,"bar/"); assertEquals("/bar/",m.get(Message.REQUEST_URI)); m.put(Message.ENDPOINT_ADDRESS,"http://localhost"); HttpUtils.updatePath(m,"bar/"); assertEquals("/bar/",m.get(Message.REQUEST_URI)); }

APIUtilityVerifier EqualityVerifier 
@Test public void testRelativize() throws Exception { URI a=new URI("file:/c:/abc/def/myDocument/doc.xml"); URI b=new URI("file:/c:/abc/def/images/subdir/image.png"); URI c=HttpUtils.relativize(a,b); assertEquals("../images/subdir/image.png",c.toString()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testReplaceLocalHostWithPort(){ Message m=new MessageImpl(); URI u=HttpUtils.toAbsoluteUri(URI.create("http://localhost:8080/bar/foo"),m); assertEquals("http://localhost:8080/bar/foo",u.toString()); }

EqualityVerifier 
@Test public void testPathDecode(){ assertEquals("+++",HttpUtils.pathDecode("+%2B+")); }

EqualityVerifier 
@Test public void testURLEncode(){ assertEquals("%2B+",HttpUtils.urlEncode("+ ")); }

Class: org.apache.cxf.jaxrs.utils.InjectionUtilsTest

APIUtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testHandleParameterWithXmlAdapterOnInterface() throws Exception { String value="1.1"; Object id=InjectionUtils.handleParameter(value,true,Id.class,Id.class,new Annotation[]{},ParameterType.PATH,createMessage()); assertTrue(id instanceof Id); assertEquals(value,((Id)id).getId()); }

EqualityVerifier 
@Test public void testCollectionType(){ assertEquals(ArrayList.class,InjectionUtils.getCollectionType(Collection.class)); assertEquals(ArrayList.class,InjectionUtils.getCollectionType(List.class)); assertEquals(HashSet.class,InjectionUtils.getCollectionType(Set.class)); assertEquals(TreeSet.class,InjectionUtils.getCollectionType(SortedSet.class)); }

EqualityVerifier 
@Test public void testInstantiateJAXBEnum(){ CarType carType=InjectionUtils.handleParameter("AUDI",false,CarType.class,CarType.class,null,ParameterType.QUERY,null); assertEquals("Type is wrong",CarType.AUDI,carType); }

EqualityVerifier 
@Test public void testGenericInterfaceType() throws NoSuchMethodException { Type str=InjectionUtils.getGenericResponseType(GenericInterface.class.getMethod("get"),TestService.class,"",String.class,new ExchangeImpl()); assertEquals(String.class,str); ParameterizedType list=(ParameterizedType)InjectionUtils.getGenericResponseType(GenericInterface.class.getMethod("list"),TestService.class,new ArrayList(),ArrayList.class,new ExchangeImpl()); assertEquals(String.class,list.getActualTypeArguments()[0]); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testExtractValuesFromBean(){ CustomerBean1 bean1=new CustomerBean1(); bean1.setA("aValue"); bean1.setB(1L); List values=new ArrayList(); values.add("lv1"); values.add("lv2"); bean1.setC(values); CustomerBean2 bean2=new CustomerBean2(); bean2.setA("aaValue"); bean2.setB(2L); values=new ArrayList(); values.add("lv11"); values.add("lv22"); bean2.setC(values); Set set=new HashSet(); set.add("set1"); set.add("set2"); bean2.setS(set); bean1.setD(bean2); MultivaluedMap map=InjectionUtils.extractValuesFromBean(bean1,""); assertEquals("Size is wrong",7,map.size()); assertEquals(1,map.get("a").size()); assertEquals("aValue",map.getFirst("a")); assertEquals(1,map.get("b").size()); assertEquals(1L,map.getFirst("b")); assertEquals(2,map.get("c").size()); assertEquals("lv1",map.get("c").get(0)); assertEquals("lv2",map.get("c").get(1)); assertEquals(1,map.get("d.a").size()); assertEquals("aaValue",map.getFirst("d.a")); assertEquals(1,map.get("d.b").size()); assertEquals(2L,map.getFirst("d.b")); assertEquals(2,map.get("d.c").size()); assertEquals("lv11",map.get("d.c").get(0)); assertEquals("lv22",map.get("d.c").get(1)); assertEquals(2,map.get("d.s").size()); assertTrue(map.get("d.s").contains("set1")); assertTrue(map.get("d.s").contains("set2")); }

Class: org.apache.cxf.jaxrs.utils.JAXRSUtilsTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testFormParametersBeanWithMap() throws Exception { Class[] argType={Customer.CustomerBean.class}; Method m=Customer.class.getMethod("testFormBean",argType); Message messageImpl=createMessage(); messageImpl.put(Message.REQUEST_URI,"/bar"); MultivaluedMap headers=new MetadataMap(); headers.putSingle("Content-Type",MediaType.APPLICATION_FORM_URLENCODED); messageImpl.put(Message.PROTOCOL_HEADERS,headers); String body="g.b=1&g.b=2"; messageImpl.setContent(InputStream.class,new ByteArrayInputStream(body.getBytes())); List params=JAXRSUtils.processParameters(new OperationResourceInfo(m,new ClassResourceInfo(Customer.class)),null,messageImpl); assertEquals("Bean should be created",1,params.size()); Customer.CustomerBean cb=(Customer.CustomerBean)params.get(0); assertNotNull(cb); assertNotNull(cb.getG()); List values=cb.getG().get("b"); assertEquals(2,values.size()); assertEquals("1",values.get(0)); assertEquals("2",values.get(1)); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testQueryParameters() throws Exception { Class[] argType={String.class,Integer.TYPE,String.class,String.class}; Method m=Customer.class.getMethod("testQuery",argType); Message messageImpl=createMessage(); messageImpl.put(Message.QUERY_STRING,"query=24&query2"); List params=JAXRSUtils.processParameters(new OperationResourceInfo(m,new ClassResourceInfo(Customer.class)),null,messageImpl); assertEquals(4,params.size()); assertEquals("Query Parameter was not matched correctly","24",params.get(0)); assertEquals("Primitive Query Parameter was not matched correctly",24,params.get(1)); assertEquals("",params.get(2)); assertNull(params.get(3)); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testArrayParamNoProvider() throws Exception { Message messageImpl=createMessage(); Class[] argType={String[].class}; Method m=Customer.class.getMethod("testCustomerParam2",argType); messageImpl.put(Message.QUERY_STRING,"p1=Fred&p1=Barry"); List params=JAXRSUtils.processParameters(new OperationResourceInfo(m,new ClassResourceInfo(Customer.class)),null,messageImpl); assertEquals(1,params.size()); String[] values=(String[])params.get(0); assertEquals("Fred",values[0]); assertEquals("Barry",values[1]); }

APIUtilityVerifier InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testContextResolverParam() throws Exception { ClassResourceInfo cri=new ClassResourceInfo(Customer.class,true); OperationResourceInfo ori=new OperationResourceInfo(Customer.class.getMethod("testContextResolvers",new Class[]{ContextResolver.class}),cri); ori.setHttpMethod("GET"); Message m=createMessage(); ContextResolver cr=new JAXBContextProvider(); ProviderFactory.getInstance(m).registerUserProvider(cr); m.put(Message.BASE_PATH,"/"); List params=JAXRSUtils.processParameters(ori,new MetadataMap(),m); assertEquals("1 parameters expected",1,params.size()); assertSame(cr.getClass(),params.get(0).getClass()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testQueryParametersIntArray() throws Exception { Class[] argType={int[].class}; Method m=Customer.class.getMethod("testQueryIntArray",argType); Message messageImpl=createMessage(); messageImpl.put(Message.QUERY_STRING,"query=1&query=2"); List params=JAXRSUtils.processParameters(new OperationResourceInfo(m,new ClassResourceInfo(Customer.class)),null,messageImpl); assertEquals(1,params.size()); int[] intValues=(int[])params.get(0); assertEquals(1,intValues[0]); assertEquals(2,intValues[1]); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testXmlAdapterBean3() throws Exception { Class[] argType={Customer.CustomerBeanInterface.class}; Method m=Customer.class.getMethod("testXmlAdapter3",argType); Message messageImpl=createMessage(); messageImpl.put(Message.QUERY_STRING,"a=aValue"); List params=JAXRSUtils.processParameters(new OperationResourceInfo(m,new ClassResourceInfo(Customer.class)),null,messageImpl); assertEquals(1,params.size()); Customer.CustomerBean bean=(Customer.CustomerBean)params.get(0); assertEquals("aValue",bean.getA()); }

APIUtilityVerifier InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testHttpContextParametersFromInterface() throws Exception { ClassResourceInfo cri=new ClassResourceInfo(Customer.class,true); Method methodToInvoke=Customer.class.getMethod("setUriInfoContext",new Class[]{UriInfo.class}); OperationResourceInfo ori=new OperationResourceInfo(methodToInvoke,AnnotationUtils.getAnnotatedMethod(Customer.class,methodToInvoke),cri); ori.setHttpMethod("GET"); Message m=new MessageImpl(); List params=JAXRSUtils.processParameters(ori,new MetadataMap(),m); assertEquals("1 parameters expected",1,params.size()); assertSame(UriInfoImpl.class,params.get(0).getClass()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testFindTargetResourceClass() throws Exception { JAXRSServiceFactoryBean sf=new JAXRSServiceFactoryBean(); sf.setResourceClasses(org.apache.cxf.jaxrs.resources.BookStoreNoSubResource.class); sf.create(); List resources=((JAXRSServiceImpl)sf.getService()).getClassResourceInfos(); String contentTypes="*/*"; OperationResourceInfo ori=findTargetResourceClass(resources,createMessage2(),"/bookstore/1/books/123/","GET",new MetadataMap(),contentTypes,getTypes("application/json,application/xml;q=0.9")); assertNotNull(ori); assertEquals("getBookJSON",ori.getMethodToInvoke().getName()); ori=findTargetResourceClass(resources,createMessage2(),"/bookstore/1/books/123","GET",new MetadataMap(),contentTypes,getTypes("application/json")); assertNotNull(ori); assertEquals("getBookJSON",ori.getMethodToInvoke().getName()); ori=findTargetResourceClass(resources,createMessage2(),"/bookstore/1/books/123","GET",new MetadataMap(),contentTypes,getTypes("application/xml")); assertNotNull(ori); assertEquals("getBook",ori.getMethodToInvoke().getName()); ori=findTargetResourceClass(resources,createMessage2(),"/bookstore/1/books","GET",new MetadataMap(),contentTypes,getTypes("application/xml")); assertNotNull(ori); assertEquals("getBooks",ori.getMethodToInvoke().getName()); ori=findTargetResourceClass(resources,createMessage2(),"/bookstore/1/books","POST",new MetadataMap(),contentTypes,getTypes("application/xml")); assertNotNull(ori); assertEquals("addBook",ori.getMethodToInvoke().getName()); ori=findTargetResourceClass(resources,createMessage2(),"/bookstore/1/books","PUT",new MetadataMap(),contentTypes,getTypes("application/xml")); assertEquals("updateBook",ori.getMethodToInvoke().getName()); ori=findTargetResourceClass(resources,createMessage2(),"/bookstore/1/books/123","DELETE",new MetadataMap(),contentTypes,getTypes("application/xml")); assertNotNull(ori); assertEquals("deleteBook",ori.getMethodToInvoke().getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testXmlAdapterBean2() throws Exception { Class[] argType={Customer.CustomerBean.class}; Method m=Customer.class.getMethod("testXmlAdapter2",argType); Message messageImpl=createMessage(); messageImpl.put(Message.QUERY_STRING,"a=aValue"); List params=JAXRSUtils.processParameters(new OperationResourceInfo(m,new ClassResourceInfo(Customer.class)),null,messageImpl); assertEquals(1,params.size()); Customer.CustomerBean bean=(Customer.CustomerBean)params.get(0); assertEquals("aValue",bean.getA()); }

APIUtilityVerifier InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testServletContextParameters() throws Exception { ClassResourceInfo cri=new ClassResourceInfo(Customer.class,true); OperationResourceInfo ori=new OperationResourceInfo(Customer.class.getMethod("testServletParams",new Class[]{HttpServletRequest.class,HttpServletResponse.class,ServletContext.class,ServletConfig.class}),cri); ori.setHttpMethod("GET"); HttpServletRequest request=EasyMock.createMock(HttpServletRequest.class); HttpServletResponse response=new HttpServletResponseFilter(EasyMock.createMock(HttpServletResponse.class),null); ServletContext context=EasyMock.createMock(ServletContext.class); ServletConfig config=EasyMock.createMock(ServletConfig.class); EasyMock.replay(request); EasyMock.replay(context); EasyMock.replay(config); Message m=new MessageImpl(); m.put(AbstractHTTPDestination.HTTP_REQUEST,request); m.put(AbstractHTTPDestination.HTTP_RESPONSE,response); m.put(AbstractHTTPDestination.HTTP_CONTEXT,context); m.put(AbstractHTTPDestination.HTTP_CONFIG,config); List params=JAXRSUtils.processParameters(ori,new MetadataMap(),m); assertEquals("4 parameters expected",4,params.size()); assertSame(request.getClass(),((HttpServletRequestFilter)params.get(0)).getRequest().getClass()); assertSame(response.getClass(),params.get(1).getClass()); assertSame(context.getClass(),params.get(2).getClass()); assertSame(config.getClass(),params.get(3).getClass()); }

APIUtilityVerifier InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testFromValueEnum() throws Exception { Class[] argType={Timezone.class}; Method m=Customer.class.getMethod("testFromValueParam",argType); Message messageImpl=createMessage(); messageImpl.put(Message.QUERY_STRING,"p1=Europe%2FLondon"); List params=JAXRSUtils.processParameters(new OperationResourceInfo(m,new ClassResourceInfo(Customer.class)),null,messageImpl); assertEquals(1,params.size()); assertSame("Timezone Parameter was not processed correctly",Timezone.EUROPE_LONDON,params.get(0)); }

EqualityVerifier 
@Test public void testDefaultValueOnField() throws Exception { ClassResourceInfo cri=new ClassResourceInfo(Customer.class,true); Customer c=new Customer(); OperationResourceInfo ori=new OperationResourceInfo(Customer.class.getMethods()[0],cri); Message m=createMessage(); m.put(Message.QUERY_STRING,""); JAXRSUtils.injectParameters(ori,c,m); assertEquals("bQuery",c.getB()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testXmlAdapterBean() throws Exception { Class[] argType={Customer.CustomerBean.class}; Method m=Customer.class.getMethod("testXmlAdapter",argType); Message messageImpl=createMessage(); messageImpl.put(Message.QUERY_STRING,"a=aValue"); List params=JAXRSUtils.processParameters(new OperationResourceInfo(m,new ClassResourceInfo(Customer.class)),null,messageImpl); assertEquals(1,params.size()); Customer.CustomerBean bean=(Customer.CustomerBean)params.get(0); assertEquals("aValue",bean.getA()); }

APIUtilityVerifier UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testCustomerParameter() throws Exception { Message messageImpl=createMessage(); ServerProviderFactory.getInstance(messageImpl).registerUserProvider(new CustomerParameterHandler()); Class[] argType={Customer.class,Customer[].class,Customer2.class}; Method m=Customer.class.getMethod("testCustomerParam",argType); messageImpl.put(Message.QUERY_STRING,"p1=Fred&p2=Barry&p3=Jack&p4=John"); List params=JAXRSUtils.processParameters(new OperationResourceInfo(m,new ClassResourceInfo(Customer.class)),null,messageImpl); assertEquals(3,params.size()); Customer c=(Customer)params.get(0); assertEquals("Fred",c.getName()); Customer c2=((Customer[])params.get(1))[0]; assertEquals("Barry",c2.getName()); Customer2 c3=(Customer2)params.get(2); assertEquals("Jack",c3.getName()); try { messageImpl.put(Message.QUERY_STRING,"p3=noName"); JAXRSUtils.processParameters(new OperationResourceInfo(m,null),null,messageImpl); fail("Customer2 constructor does not accept names starting with lower-case chars"); } catch ( Exception ex) { } }

EqualityVerifier 
@Test public void testGetMediaTypes(){ List types=JAXRSUtils.getMediaTypes(new String[]{"text/xml"}); assertEquals(1,types.size()); assertEquals(MediaType.TEXT_XML_TYPE,types.get(0)); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testInjectCustomContext() throws Exception { final CustomerContext contextImpl=new CustomerContext(){ public String get(){ return "customerContext"; } } ; JAXRSServerFactoryBean sf=new JAXRSServerFactoryBean(); Customer customer=new Customer(); sf.setServiceBeanObjects(customer); sf.setProvider(new ContextProvider(){ public CustomerContext createContext( Message message){ return contextImpl; } } ); sf.setStart(false); Server s=sf.create(); assertTrue(customer.getCustomerContext() instanceof ThreadLocalProxy); invokeCustomerMethod(sf.getServiceFactory().getClassResourceInfo().get(0),customer,s); CustomerContext context=customer.getCustomerContext(); assertEquals("customerContext",context.get()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testConversion() throws Exception { ClassResourceInfo cri=new ClassResourceInfo(Customer.class,true); OperationResourceInfo ori=new OperationResourceInfo(Customer.class.getMethod("testConversion",new Class[]{PathSegmentImpl.class,SimpleFactory.class}),cri); ori.setHttpMethod("GET"); ori.setURITemplate(new URITemplate("{id1}/{id2}")); MultivaluedMap values=new MetadataMap(); values.putSingle("id1","1"); values.putSingle("id2","2"); Message m=createMessage(); List params=JAXRSUtils.processParameters(ori,values,m); PathSegment ps=(PathSegment)params.get(0); assertEquals("1",ps.getPath()); SimpleFactory sf=(SimpleFactory)params.get(1); assertEquals(2,sf.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@SuppressWarnings("unchecked") @Test public void testQueryParamAsListWithDefaultValue() throws Exception { Class[] argType={List.class,List.class,List.class,Integer[].class,List.class,List.class}; Method m=Customer.class.getMethod("testQueryAsList",argType); Message messageImpl=createMessage(); messageImpl.put(Message.QUERY_STRING,"query2=query2Value&query2=query2Value2&query3=1&query3=2&query4"); List params=JAXRSUtils.processParameters(new OperationResourceInfo(m,new ClassResourceInfo(Customer.class)),null,messageImpl); assertEquals(6,params.size()); List queryList=(List)params.get(0); assertNotNull(queryList); assertEquals(1,queryList.size()); assertEquals("default",queryList.get(0)); List queryList2=(List)params.get(1); assertNotNull(queryList2); assertEquals(2,queryList2.size()); assertEquals("query2Value",queryList2.get(0)); assertEquals("query2Value2",queryList2.get(1)); List queryList3=(List)params.get(2); assertNotNull(queryList3); assertEquals(2,queryList3.size()); assertEquals(Integer.valueOf(1),queryList3.get(0)); assertEquals(Integer.valueOf(2),queryList3.get(1)); Integer[] queryList3Array=(Integer[])params.get(3); assertNotNull(queryList3Array); assertEquals(2,queryList3Array.length); assertEquals(Integer.valueOf(1),queryList3Array[0]); assertEquals(Integer.valueOf(2),queryList3Array[1]); List queryList4=(List)params.get(4); assertNotNull(queryList4); assertEquals(1,queryList4.size()); assertEquals("",queryList4.get(0)); List queryList5=(List)params.get(5); assertNotNull(queryList5); assertEquals(0,queryList5.size()); }

EqualityVerifier 
@Test public void testIntersectMimeTypesCompositeSubtype2() throws Exception { List candidateList=JAXRSUtils.intersectMimeTypes("application/bar+xml","application/bar+xml"); assertEquals(1,candidateList.size()); assertEquals("application/bar+xml",candidateList.get(0).toString()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@SuppressWarnings("unchecked") @Test public void testMatrixParameters() throws Exception { Class[] argType={String.class,String.class,String.class,String.class,List.class,String.class}; Method m=Customer.class.getMethod("testMatrixParam",argType); Message messageImpl=createMessage(); messageImpl.put(Message.REQUEST_URI,"/foo;p4=0;p3=3/bar;p1=1;p2/baz;p4=4;p4=5;p5"); List params=JAXRSUtils.processParameters(new OperationResourceInfo(m,new ClassResourceInfo(Customer.class)),null,messageImpl); assertEquals("5 Matrix params should've been identified",6,params.size()); assertEquals("First Matrix Parameter not matched correctly","1",params.get(0)); assertEquals("Second Matrix Parameter was not matched correctly","",params.get(1)); assertEquals("Third Matrix Parameter was not matched correctly","3",params.get(2)); assertEquals("Fourth Matrix Parameter was not matched correctly","0",params.get(3)); List list=(List)params.get(4); assertEquals(3,list.size()); assertEquals("0",list.get(0)); assertEquals("4",list.get(1)); assertEquals("5",list.get(2)); assertEquals("Sixth Matrix Parameter was not matched correctly","",params.get(5)); }

APIUtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testIntersectMimeTypesTwoArray() throws Exception { List acceptedMimeTypes=JAXRSUtils.parseMediaTypes("application/mytype, application/xml, application/json"); List candidateList=JAXRSUtils.intersectMimeTypes(acceptedMimeTypes,JAXRSUtils.ALL_TYPES); assertEquals(3,candidateList.size()); for ( MediaType type : candidateList) { assertTrue("application/mytype".equals(type.toString()) || "application/xml".equals(type.toString()) || "application/json".equals(type.toString())); } acceptedMimeTypes=Collections.singletonList(JAXRSUtils.ALL_TYPES); List providerMimeTypes=JAXRSUtils.parseMediaTypes("application/mytype, application/xml, application/json"); candidateList=JAXRSUtils.intersectMimeTypes(acceptedMimeTypes,providerMimeTypes,false); assertEquals(3,candidateList.size()); for ( MediaType type : candidateList) { assertTrue("application/mytype".equals(type.toString()) || "application/xml".equals(type.toString()) || "application/json".equals(type.toString())); } acceptedMimeTypes=JAXRSUtils.parseMediaTypes("application/mytype,application/xml"); candidateList=JAXRSUtils.intersectMimeTypes(acceptedMimeTypes,MediaType.valueOf("application/json")); assertEquals(0,candidateList.size()); }

EqualityVerifier 
@Test public void testGetMediaTypes3(){ List types=JAXRSUtils.getMediaTypes(new String[]{"text/xml, text/plain"}); assertEquals(2,types.size()); assertEquals(MediaType.TEXT_XML_TYPE,types.get(0)); assertEquals(MediaType.TEXT_PLAIN_TYPE,types.get(1)); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testQueryParametersIntegerArray() throws Exception { Class[] argType={Integer[].class}; Method m=Customer.class.getMethod("testQueryIntegerArray",argType); Message messageImpl=createMessage(); messageImpl.put(Message.QUERY_STRING,"query=1&query=2"); List params=JAXRSUtils.processParameters(new OperationResourceInfo(m,new ClassResourceInfo(Customer.class)),null,messageImpl); assertEquals(1,params.size()); Integer[] intValues=(Integer[])params.get(0); assertEquals(1,(int)intValues[0]); assertEquals(2,(int)intValues[1]); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testMultipleQueryParameters() throws Exception { Class[] argType={String.class,String.class,Long.class,Boolean.TYPE,char.class,String.class}; Method m=Customer.class.getMethod("testMultipleQuery",argType); Message messageImpl=createMessage(); messageImpl.put(Message.QUERY_STRING,"query=first&query2=second&query3=3&query4=true&query6"); List params=JAXRSUtils.processParameters(new OperationResourceInfo(m,new ClassResourceInfo(Customer.class)),null,messageImpl); assertEquals("First Query Parameter of multiple was not matched correctly","first",params.get(0)); assertEquals("Second Query Parameter of multiple was not matched correctly","second",params.get(1)); assertEquals("Third Query Parameter of multiple was not matched correctly",new Long(3),params.get(2)); assertEquals("Fourth Query Parameter of multiple was not matched correctly",Boolean.TRUE,params.get(3)); assertEquals("Fifth Query Parameter of multiple was not matched correctly",'\u0000',params.get(4)); assertEquals("Six Query Parameter of multiple was not matched correctly","",params.get(5)); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testCookieParameters() throws Exception { Class[] argType={String.class,Set.class,String.class,Set.class}; Method m=Customer.class.getMethod("testCookieParam",argType); Message messageImpl=createMessage(); MultivaluedMap headers=new MetadataMap(); headers.add("Cookie","c1=c1Value"); messageImpl.put(Message.PROTOCOL_HEADERS,headers); List params=JAXRSUtils.processParameters(new OperationResourceInfo(m,new ClassResourceInfo(Customer.class)),null,messageImpl); assertEquals(params.size(),4); assertEquals("c1Value",params.get(0)); Set set1=CastUtils.cast((Set)params.get(1)); assertEquals(1,set1.size()); assertTrue(set1.contains(Cookie.valueOf("c1=c1Value"))); assertEquals("c2Value",params.get(2)); Set set2=CastUtils.cast((Set)params.get(3)); assertTrue(set2.contains("c2Value")); assertEquals(1,set2.size()); }

EqualityVerifier 
@Test public void testIntersectMimeTypesCompositeSubtype() throws Exception { List candidateList=JAXRSUtils.intersectMimeTypes("application/bar+xml","application/*+xml"); assertEquals(1,candidateList.size()); assertEquals("application/bar+xml",candidateList.get(0).toString()); }

EqualityVerifier 
@Test public void testIntersectMimeTypesCompositeSubtype4() throws Exception { List candidateList=JAXRSUtils.intersectMimeTypes("application/*+xml","application/bar+json"); assertEquals(0,candidateList.size()); }

EqualityVerifier 
@Test public void testGetMediaTypes2(){ List types=JAXRSUtils.getMediaTypes(new String[]{"text/xml","text/plain"}); assertEquals(2,types.size()); assertEquals(MediaType.TEXT_XML_TYPE,types.get(0)); assertEquals(MediaType.TEXT_PLAIN_TYPE,types.get(1)); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testSelectBetweenMultipleResourceClasses() throws Exception { JAXRSServiceFactoryBean sf=new JAXRSServiceFactoryBean(); sf.setResourceClasses(org.apache.cxf.jaxrs.resources.BookStoreNoSubResource.class,org.apache.cxf.jaxrs.resources.BookStore.class); sf.create(); List resources=((JAXRSServiceImpl)sf.getService()).getClassResourceInfos(); ClassResourceInfo bStore=firstResource(JAXRSUtils.selectResourceClass(resources,"/bookstore",null)); assertEquals(bStore.getResourceClass(),org.apache.cxf.jaxrs.resources.BookStore.class); bStore=firstResource(JAXRSUtils.selectResourceClass(resources,"/bookstore/",null)); assertEquals(bStore.getResourceClass(),org.apache.cxf.jaxrs.resources.BookStore.class); bStore=firstResource(JAXRSUtils.selectResourceClass(resources,"/bookstore/bar",null)); assertEquals(bStore.getResourceClass(),org.apache.cxf.jaxrs.resources.BookStoreNoSubResource.class); }

EqualityVerifier 
@Test public void testIntersectMimeTypesCompositeSubtype3() throws Exception { List candidateList=JAXRSUtils.intersectMimeTypes("application/*+xml","application/bar+xml"); assertEquals(1,candidateList.size()); assertEquals("application/bar+xml",candidateList.get(0).toString()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testLocaleParameter() throws Exception { Message messageImpl=createMessage(); ProviderFactory.getInstance(messageImpl).registerUserProvider(new LocaleParameterHandler()); Class[] argType={Locale.class}; Method m=Customer.class.getMethod("testLocaleParam",argType); messageImpl.put(Message.QUERY_STRING,"p1=en_us"); List params=JAXRSUtils.processParameters(new OperationResourceInfo(m,new ClassResourceInfo(Customer.class)),null,messageImpl); assertEquals(1,params.size()); Locale l=(Locale)params.get(0); assertEquals("en",l.getLanguage()); assertEquals("US",l.getCountry()); }

InternalCallVerifier EqualityVerifier 
@Test public void testParamAnnotationOnMethod() throws Exception { ClassResourceInfo cri=new ClassResourceInfo(Customer.class,true); Customer c=new Customer(); OperationResourceInfo ori=new OperationResourceInfo(Customer.class.getMethods()[0],cri); Message m=createMessage(); MultivaluedMap headers=new MetadataMap(); headers.add("AHeader2","theAHeader2"); m.put(Message.PROTOCOL_HEADERS,headers); m.put(Message.QUERY_STRING,"a_value=aValue&query2=b"); JAXRSUtils.injectParameters(ori,c,m); assertEquals("aValue",c.getQueryParam()); assertEquals("theAHeader2",c.getAHeader2()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testSelectBetweenMultipleResourceClasses2() throws Exception { JAXRSServiceFactoryBean sf=new JAXRSServiceFactoryBean(); sf.setResourceClasses(org.apache.cxf.jaxrs.resources.TestResourceTemplate1.class,org.apache.cxf.jaxrs.resources.TestResourceTemplate2.class); sf.create(); List resources=((JAXRSServiceImpl)sf.getService()).getClassResourceInfos(); ClassResourceInfo bStore=firstResource(JAXRSUtils.selectResourceClass(resources,"/1",null)); assertEquals(bStore.getResourceClass(),org.apache.cxf.jaxrs.resources.TestResourceTemplate1.class); bStore=firstResource(JAXRSUtils.selectResourceClass(resources,"/1/",null)); assertEquals(bStore.getResourceClass(),org.apache.cxf.jaxrs.resources.TestResourceTemplate1.class); bStore=firstResource(JAXRSUtils.selectResourceClass(resources,"/1/foo",null)); assertEquals(bStore.getResourceClass(),org.apache.cxf.jaxrs.resources.TestResourceTemplate2.class); bStore=firstResource(JAXRSUtils.selectResourceClass(resources,"/1/foo/bar",null)); assertEquals(bStore.getResourceClass(),org.apache.cxf.jaxrs.resources.TestResourceTemplate2.class); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testQueryParameter() throws Exception { Message messageImpl=createMessage(); ProviderFactory.getInstance(messageImpl).registerUserProvider(new GenericObjectParameterHandler()); Class[] argType={Query.class}; Method m=Customer.class.getMethod("testGenericObjectParam",argType); messageImpl.put(Message.QUERY_STRING,"p1=thequery"); List params=JAXRSUtils.processParameters(new OperationResourceInfo(m,new ClassResourceInfo(Customer.class)),null,messageImpl); assertEquals(1,params.size()); @SuppressWarnings("unchecked") Query query=(Query)params.get(0); assertEquals("thequery",query.getEntity()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testMultipleCookieParameters() throws Exception { Class[] argType={String.class,String.class,Cookie.class}; Method m=Customer.class.getMethod("testMultipleCookieParam",argType); Message messageImpl=createMessage(); MultivaluedMap headers=new MetadataMap(); headers.add("Cookie","c1=c1Value; c2=c2Value"); headers.add("Cookie","c3=c3Value"); messageImpl.put(Message.PROTOCOL_HEADERS,headers); List params=JAXRSUtils.processParameters(new OperationResourceInfo(m,new ClassResourceInfo(Customer.class)),null,messageImpl); assertEquals(params.size(),3); assertEquals("c1Value",params.get(0)); assertEquals("c2Value",params.get(1)); assertEquals("c3Value",((Cookie)params.get(2)).getValue()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testSelectBetweenMultipleResourceClasses3() throws Exception { JAXRSServiceFactoryBean sf=new JAXRSServiceFactoryBean(); sf.setResourceClasses(org.apache.cxf.jaxrs.resources.TestResourceTemplate4.class,org.apache.cxf.jaxrs.resources.TestResourceTemplate3.class); sf.create(); List resources=((JAXRSServiceImpl)sf.getService()).getClassResourceInfos(); ClassResourceInfo bStore=firstResource(JAXRSUtils.selectResourceClass(resources,"/",null)); assertEquals(bStore.getResourceClass(),org.apache.cxf.jaxrs.resources.TestResourceTemplate3.class); bStore=firstResource(JAXRSUtils.selectResourceClass(resources,"/test",null)); assertEquals(bStore.getResourceClass(),org.apache.cxf.jaxrs.resources.TestResourceTemplate4.class); }

EqualityVerifier 
@Test public void testIntersectMimeTypesCompositeSubtype5() throws Exception { List candidateList=JAXRSUtils.intersectMimeTypes("application/bar+xml","application/bar+*"); assertEquals(1,candidateList.size()); assertEquals("application/bar+xml",candidateList.get(0).toString()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testFindTargetResourceClassWithSubResource() throws Exception { JAXRSServiceFactoryBean sf=new JAXRSServiceFactoryBean(); sf.setResourceClasses(org.apache.cxf.jaxrs.resources.BookStore.class); sf.create(); List resources=((JAXRSServiceImpl)sf.getService()).getClassResourceInfos(); String contentTypes="*/*"; OperationResourceInfo ori=findTargetResourceClass(resources,createMessage2(),"/bookstore/books/sub/123","GET",new MetadataMap(),contentTypes,getTypes("*/*")); assertNotNull(ori); assertEquals("getBook",ori.getMethodToInvoke().getName()); ori=findTargetResourceClass(resources,createMessage2(),"/bookstore/books/123/true/chapter/1","GET",new MetadataMap(),contentTypes,getTypes("*/*")); assertNotNull(ori); assertEquals("getNewBook",ori.getMethodToInvoke().getName()); ori=findTargetResourceClass(resources,createMessage2(),"/bookstore/books","POST",new MetadataMap(),contentTypes,getTypes("*/*")); assertNotNull(ori); assertEquals("addBook",ori.getMethodToInvoke().getName()); ori=findTargetResourceClass(resources,createMessage2(),"/bookstore/books","PUT",new MetadataMap(),contentTypes,getTypes("*/*")); assertNotNull(ori); assertEquals("updateBook",ori.getMethodToInvoke().getName()); ori=findTargetResourceClass(resources,createMessage2(),"/bookstore/books/123","DELETE",new MetadataMap(),contentTypes,getTypes("*/*")); assertNotNull(ori); assertEquals("deleteBook",ori.getMethodToInvoke().getName()); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testExceptionDuringConstruction() throws Exception { Class[] argType={CustomerGender.class}; Method m=Customer.class.getMethod("testWrongType2",argType); Message messageImpl=createMessage(); messageImpl.put(Message.QUERY_STRING,"p1=3"); try { JAXRSUtils.processParameters(new OperationResourceInfo(m,new ClassResourceInfo(Customer.class)),null,messageImpl); fail("CustomerGender have no instance with name 3"); } catch ( WebApplicationException ex) { assertEquals(404,ex.getResponse().getStatus()); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testMatrixAndPathSegmentParameters() throws Exception { Class[] argType={PathSegment.class,String.class}; Method m=Customer.class.getMethod("testPathSegment",argType); Message messageImpl=createMessage(); messageImpl.put(Message.REQUEST_URI,"/bar%20foo;p4=0%201"); MultivaluedMap values=new MetadataMap(); values.add("ps","bar%20foo;p4=0%201"); List params=JAXRSUtils.processParameters(new OperationResourceInfo(m,new ClassResourceInfo(Customer.class)),values,messageImpl); assertEquals("2 params should've been identified",2,params.size()); PathSegment ps=(PathSegment)params.get(0); assertEquals("bar foo",ps.getPath()); assertEquals(1,ps.getMatrixParameters().size()); assertEquals("0 1",ps.getMatrixParameters().getFirst("p4")); assertEquals("bar foo",params.get(1)); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testFormParametersBeanWithBoolean() throws Exception { Class[] argType={Customer.CustomerBean.class}; Method m=Customer.class.getMethod("testFormBean",argType); Message messageImpl=createMessage(); messageImpl.put(Message.REQUEST_URI,"/bar"); MultivaluedMap headers=new MetadataMap(); headers.putSingle("Content-Type",MediaType.APPLICATION_FORM_URLENCODED); messageImpl.put(Message.PROTOCOL_HEADERS,headers); String body="a=aValue&b=123&cb=true"; messageImpl.setContent(InputStream.class,new ByteArrayInputStream(body.getBytes())); List params=JAXRSUtils.processParameters(new OperationResourceInfo(m,new ClassResourceInfo(Customer.class)),null,messageImpl); assertEquals("Bean should be created",1,params.size()); Customer.CustomerBean cb=(Customer.CustomerBean)params.get(0); assertNotNull(cb); assertEquals("aValue",cb.getA()); assertEquals(new Long(123),cb.getB()); assertTrue(cb.isCb()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@SuppressWarnings("unchecked") @Test public void testFormParametersAndMap() throws Exception { Class[] argType={MultivaluedMap.class,String.class,List.class}; Method m=Customer.class.getMethod("testMultivaluedMapAndFormParam",argType); final Message messageImpl=createMessage(); String body="p1=1&p2=2&p2=3"; messageImpl.put(Message.REQUEST_URI,"/foo"); messageImpl.put("Content-Type",MediaType.APPLICATION_FORM_URLENCODED); messageImpl.setContent(InputStream.class,new ByteArrayInputStream(body.getBytes())); ProviderFactory.getInstance(messageImpl).registerUserProvider(new FormEncodingProvider(){ @Override protected void persistParamsOnMessage( MultivaluedMap params){ messageImpl.put(FormUtils.FORM_PARAM_MAP,params); } } ); List params=JAXRSUtils.processParameters(new OperationResourceInfo(m,new ClassResourceInfo(Customer.class)),new MetadataMap(),messageImpl); assertEquals("3 params should've been identified",3,params.size()); MultivaluedMap map=(MultivaluedMap)params.get(0); assertEquals(2,map.size()); assertEquals(1,map.get("p1").size()); assertEquals("First map parameter not matched correctly","1",map.getFirst("p1")); assertEquals(2,map.get("p2").size()); assertEquals("2",map.get("p2").get(0)); assertEquals("3",map.get("p2").get(1)); assertEquals("First Form Parameter not matched correctly","1",params.get(1)); List list=(List)params.get(2); assertEquals(2,list.size()); assertEquals("2",list.get(0)); assertEquals("3",list.get(1)); }

APIUtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testIntersectMimeTypes() throws Exception { List methodMimeTypes=new ArrayList(JAXRSUtils.parseMediaTypes("application/mytype,application/xml,application/json")); MediaType acceptContentType=MediaType.valueOf("application/json"); List candidateList=JAXRSUtils.intersectMimeTypes(methodMimeTypes,MediaType.valueOf("application/json")); assertEquals(1,candidateList.size()); assertTrue(candidateList.get(0).toString().equals("application/json")); methodMimeTypes=JAXRSUtils.parseMediaTypes("application/mytype, application/json, application/xml"); candidateList=JAXRSUtils.intersectMimeTypes(methodMimeTypes,MediaType.valueOf("application/json")); assertEquals(1,candidateList.size()); assertTrue(candidateList.get(0).toString().equals("application/json")); candidateList=JAXRSUtils.intersectMimeTypes("application/mytype,application/json,application/xml","*/*"); assertEquals(3,candidateList.size()); methodMimeTypes=JAXRSUtils.parseMediaTypes("text/html,text/xml,application/xml"); acceptContentType=MediaType.valueOf("text/*"); candidateList=JAXRSUtils.intersectMimeTypes(methodMimeTypes,acceptContentType); assertEquals(2,candidateList.size()); for ( MediaType type : candidateList) { assertTrue("text/html".equals(type.toString()) || "text/xml".equals(type.toString())); } candidateList=JAXRSUtils.intersectMimeTypes("*/*","application/json"); assertEquals(1,candidateList.size()); assertTrue("application/json".equals(candidateList.get(0).toString())); candidateList=JAXRSUtils.intersectMimeTypes("application/*","application/json"); assertEquals(1,candidateList.size()); assertTrue("application/json".equals(candidateList.get(0).toString())); candidateList=JAXRSUtils.intersectMimeTypes("*/*","*/*"); assertEquals(1,candidateList.size()); assertTrue("*/*".equals(candidateList.get(0).toString())); }

APIUtilityVerifier InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@SuppressWarnings("unchecked") @Test public void testHttpContextParameters() throws Exception { ClassResourceInfo cri=new ClassResourceInfo(Customer.class,true); OperationResourceInfo ori=new OperationResourceInfo(Customer.class.getMethod("testParams",new Class[]{UriInfo.class,HttpHeaders.class,Request.class,SecurityContext.class,Providers.class,String.class,List.class}),cri); ori.setHttpMethod("GET"); MultivaluedMap headers=new MetadataMap(); headers.add("Foo","bar, baz"); Message m=createMessage(); m.put("org.apache.cxf.http.header.split","true"); m.put(Message.PROTOCOL_HEADERS,headers); List params=JAXRSUtils.processParameters(ori,new MetadataMap(),m); assertEquals("7 parameters expected",7,params.size()); assertSame(UriInfoImpl.class,params.get(0).getClass()); assertSame(HttpHeadersImpl.class,params.get(1).getClass()); assertSame(RequestImpl.class,params.get(2).getClass()); assertSame(SecurityContextImpl.class,params.get(3).getClass()); assertSame(ProvidersImpl.class,params.get(4).getClass()); assertSame(String.class,params.get(5).getClass()); assertEquals("Wrong header param","bar",params.get(5)); List values=(List)params.get(6); assertEquals("Wrong headers size",2,values.size()); assertEquals("Wrong 1st header param","bar",values.get(0)); assertEquals("Wrong 2nd header param","baz",values.get(1)); }

APIUtilityVerifier InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testFromStringParameters() throws Exception { Class[] argType={UUID.class,CustomerGender.class,CustomerGender.class}; Method m=Customer.class.getMethod("testFromStringParam",argType); UUID u=UUID.randomUUID(); Message messageImpl=createMessage(); messageImpl.put(Message.QUERY_STRING,"p1=" + u.toString() + "&p2=1&p3=2"); List params=JAXRSUtils.processParameters(new OperationResourceInfo(m,new ClassResourceInfo(Customer.class)),null,messageImpl); assertEquals(3,params.size()); assertEquals("Query UUID Parameter was not matched correctly",u.toString(),params.get(0).toString()); assertSame(CustomerGender.FEMALE,params.get(1)); assertSame(CustomerGender.MALE,params.get(2)); }

InternalCallVerifier EqualityVerifier 
@Test public void testParamAnnotationOnField() throws Exception { ClassResourceInfo cri=new ClassResourceInfo(Customer.class,true); Customer c=new Customer(); OperationResourceInfo ori=new OperationResourceInfo(Customer.class.getMethods()[0],cri); Message m=createMessage(); MultivaluedMap headers=new MetadataMap(); headers.add("AHeader","theAHeader"); m.put(Message.PROTOCOL_HEADERS,headers); m.put(Message.QUERY_STRING,"b=bValue"); JAXRSUtils.injectParameters(ori,c,m); assertEquals("bValue",c.getB()); assertEquals("theAHeader",c.getAHeader()); }

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testWrongType() throws Exception { Class[] argType={HashMap.class}; Method m=Customer.class.getMethod("testWrongType",argType); Message messageImpl=createMessage(); messageImpl.put(Message.QUERY_STRING,"p1=1"); try { JAXRSUtils.processParameters(new OperationResourceInfo(m,new ClassResourceInfo(Customer.class)),null,messageImpl); fail("HashMap can not be handled as parameter"); } catch ( WebApplicationException ex) { assertEquals(500,ex.getResponse().getStatus()); assertEquals("Parameter Class java.util.HashMap has no constructor with " + "single String parameter, static valueOf(String) or fromString(String) methods",ex.getResponse().getEntity().toString()); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testFindTargetResourceClassWithTemplates() throws Exception { JAXRSServiceFactoryBean sf=new JAXRSServiceFactoryBean(); sf.setResourceClasses(org.apache.cxf.jaxrs.resources.BookStoreTemplates.class); sf.create(); List resources=((JAXRSServiceImpl)sf.getService()).getClassResourceInfos(); String contentTypes="*/*"; MetadataMap values=new MetadataMap(); OperationResourceInfo ori=findTargetResourceClass(resources,createMessage2(),"/1/2/","GET",values,contentTypes,getTypes("*/*")); assertNotNull(ori); assertEquals("getBooks",ori.getMethodToInvoke().getName()); assertEquals("Only id and final match groups should be there",2,values.size()); assertEquals("2 {id} values should've been picked up",2,values.get("id").size()); assertEquals("FINAL_MATCH_GROUP should've been picked up",1,values.get(URITemplate.FINAL_MATCH_GROUP).size()); assertEquals("First {id} is 1","1",values.getFirst("id")); assertEquals("Second id is 2","2",values.get("id").get(1)); values=new MetadataMap(); ori=findTargetResourceClass(resources,createMessage2(),"/2","POST",values,contentTypes,getTypes("*/*")); assertNotNull(ori); assertEquals("updateBookStoreInfo",ori.getMethodToInvoke().getName()); assertEquals("Only id and final match groups should be there",2,values.size()); assertEquals("Only single {id} should've been picked up",1,values.get("id").size()); assertEquals("FINAL_MATCH_GROUP should've been picked up",1,values.get(URITemplate.FINAL_MATCH_GROUP).size()); assertEquals("Only the first {id} should've been picked up","2",values.getFirst("id")); values=new MetadataMap(); ori=findTargetResourceClass(resources,createMessage2(),"/3/4","PUT",values,contentTypes,getTypes("*/*")); assertNotNull(ori); assertEquals("updateBook",ori.getMethodToInvoke().getName()); assertEquals("Only the first {id} should've been picked up",3,values.size()); assertEquals("Only the first {id} should've been picked up",1,values.get("id").size()); assertEquals("Only the first {id} should've been picked up",1,values.get("bookId").size()); assertEquals("Only the first {id} should've been picked up",1,values.get(URITemplate.FINAL_MATCH_GROUP).size()); assertEquals("Only the first {id} should've been picked up","3",values.getFirst("id")); assertEquals("Only the first {id} should've been picked up","4",values.getFirst("bookId")); }

Class: org.apache.cxf.jaxrs.utils.ResourceUtilsTest

EqualityVerifier NullVerifier HybridVerifier 
@Test public void testFindResourceConstructor(){ Constructor c=ResourceUtils.findResourceConstructor(Customer.class,true); assertNotNull(c); assertEquals(2,c.getParameterTypes().length); assertEquals(UriInfo.class,c.getParameterTypes()[0]); assertEquals(String.class,c.getParameterTypes()[1]); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testClassResourceInfoUserResource() throws Exception { UserResource ur=new UserResource(); ur.setName(HashMap.class.getName()); ur.setPath("/hashmap"); UserOperation op=new UserOperation(); op.setPath("/key/{id}"); op.setName("get"); op.setVerb("POST"); op.setParameters(Collections.singletonList(new Parameter(ParameterType.PATH,"id"))); ur.setOperations(Collections.singletonList(op)); Map resources=new HashMap(); resources.put(ur.getName(),ur); ClassResourceInfo cri=ResourceUtils.createClassResourceInfo(resources,ur,null,true,true,BusFactory.getDefaultBus()); assertNotNull(cri); assertEquals("/hashmap",cri.getURITemplate().getValue()); Method method=HashMap.class.getMethod("get",new Class[]{Object.class}); OperationResourceInfo ori=cri.getMethodDispatcher().getOperationResourceInfo(method); assertNotNull(ori); assertEquals("/key/{id}",ori.getURITemplate().getValue()); List params=ori.getParameters(); assertNotNull(params); Parameter p=params.get(0); assertEquals("id",p.getName()); }

APIUtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testGetAllJaxbClasses2(){ ClassResourceInfo cri1=ResourceUtils.createClassResourceInfo(IProductResource.class,IProductResource.class,true,true); Map,Type> types=ResourceUtils.getAllRequestResponseTypes(Collections.singletonList(cri1),true).getAllTypes(); assertEquals(2,types.size()); assertTrue(types.containsKey(Book.class)); assertTrue(types.containsKey(Chapter.class)); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testClassResourceInfoWithOverride() throws Exception { ClassResourceInfo cri=ResourceUtils.createClassResourceInfo(ExampleImpl.class,ExampleImpl.class,true,true); assertNotNull(cri); Method m=ExampleImpl.class.getMethod("get"); OperationResourceInfo ori=cri.getMethodDispatcher().getOperationResourceInfo(m); assertNotNull(ori); assertEquals("GET",ori.getHttpMethod()); }

APIUtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testGetAllJaxbClassesComplexGenericType(){ ClassResourceInfo cri1=ResourceUtils.createClassResourceInfo(OrderResource.class,OrderResource.class,true,true); Map,Type> types=ResourceUtils.getAllRequestResponseTypes(Collections.singletonList(cri1),true).getAllTypes(); assertEquals(2,types.size()); assertTrue(types.containsKey(OrderItemsDTO.class)); assertTrue(types.containsKey(OrderItemDTO.class)); }

APIUtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testGetAllJaxbClasses(){ ClassResourceInfo cri1=ResourceUtils.createClassResourceInfo(BookInterface.class,BookInterface.class,true,true); Map,Type> types=ResourceUtils.getAllRequestResponseTypes(Collections.singletonList(cri1),true).getAllTypes(); assertEquals(2,types.size()); assertTrue(types.containsKey(Book.class)); assertTrue(types.containsKey(Chapter.class)); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testUserResourceFromFile() throws Exception { List list=ResourceUtils.getUserResources("classpath:/resources.xml"); assertNotNull(list); assertEquals(1,list.size()); UserResource resource=list.get(0); assertEquals("java.util.Map",resource.getName()); assertEquals("map",resource.getPath()); assertEquals("application/xml",resource.getProduces()); assertEquals("application/json",resource.getConsumes()); UserOperation oper=resource.getOperations().get(0); assertEquals("putAll",oper.getName()); assertEquals("/putAll",oper.getPath()); assertEquals("PUT",oper.getVerb()); assertEquals("application/json",oper.getProduces()); assertEquals("application/xml",oper.getConsumes()); Parameter p=oper.getParameters().get(0); assertEquals("map",p.getName()); assertEquals("emptyMap",p.getDefaultValue()); assertTrue(p.isEncoded()); assertEquals("REQUEST_BODY",p.getType().toString()); }

Class: org.apache.cxf.jaxws.CodeFirstTest

InternalCallVerifier EqualityVerifier 
@Test public void testRpcClient() throws Exception { SayHiImpl serviceImpl=new SayHiImpl(); try (EndpointImpl ep=new EndpointImpl(getBus(),serviceImpl,(String)null)){ ep.publish("local://localhost:9090/hello"); QName serviceName=new QName("http://mynamespace.com/","SayHiService"); QName portName=new QName("http://mynamespace.com/","HelloPort"); ServiceImpl service=new ServiceImpl(getBus(),(URL)null,serviceName,null); service.addPort(portName,"http://schemas.xmlsoap.org/soap/","local://localhost:9090/hello"); SayHi proxy=service.getPort(portName,SayHi.class); long res=proxy.sayHi(3); assertEquals(3,res); String[] strInput=new String[2]; strInput[0]="Hello"; strInput[1]="Bonjour"; String[] strings=proxy.getStringArray(strInput); assertEquals(strings.length,2); assertEquals(strings[0],"HelloHello"); assertEquals(strings[1],"BonjourBonjour"); } }

InternalCallVerifier EqualityVerifier 
@Test public void testCXF1510() throws Exception { JaxWsServerFactoryBean factory=new JaxWsServerFactoryBean(); factory.setServiceClass(NoRootBare.class); factory.setServiceBean(new NoRootBareImpl()); factory.setAddress("local://localhost/testNoRootBare"); Server server=factory.create(); server.start(); QName serviceName=new QName("http://service.jaxws.cxf.apache.org/","NoRootBareService"); QName portName=new QName("http://service.jaxws.cxf.apache.org/","NoRootBarePort"); ServiceImpl service=new ServiceImpl(getBus(),(URL)null,serviceName,null); service.addPort(portName,"http://schemas.xmlsoap.org/soap/","local://localhost/testNoRootBare"); NoRootBare proxy=service.getPort(portName,NoRootBare.class); assertEquals("hello",proxy.echoString(new NoRootRequest("hello")).getMessage()); }

InternalCallVerifier EqualityVerifier 
@Test public void testCXF1758() throws Exception { JaxWsServerFactoryBean factory=new JaxWsServerFactoryBean(); factory.setServiceBean(new GenericsService2Impl()); factory.setAddress("local://localhost/test"); Server server=null; server=factory.create(); Document doc=getWSDLDocument(server); assertXPathEquals("//xsd:schema/xsd:complexType[@name='convert']/xsd:sequence/xsd:element/@type",Constants.XSD_INT,doc); factory=new JaxWsServerFactoryBean(); factory.setServiceBean(new GenericsService2(){ public Double convert( Float t){ return t.doubleValue(); } public GenericsService2.Value convert2( GenericsService2.Value in){ return new GenericsService2.Value(in.getValue().doubleValue()); } } ); factory.setAddress("local://localhost/test2"); server=factory.create(); Document doc2=getWSDLDocument(server); assertXPathEquals("//xsd:schema/xsd:complexType[@name='convert']/xsd:sequence/" + "xsd:element/@type",Constants.XSD_FLOAT,doc2); QName serviceName=new QName("http://service.jaxws.cxf.apache.org/","Generics2"); QName portName=new QName("http://service.jaxws.cxf.apache.org/","Generics2Port"); ServiceImpl service=new ServiceImpl(getBus(),(URL)null,serviceName,null); service.addPort(portName,"http://schemas.xmlsoap.org/soap/","local://localhost/test2"); GenericsService2Typed proxy=service.getPort(portName,GenericsService2Typed.class); assertEquals("",3.14d,proxy.convert(3.14f),0.00001); assertEquals("",3.14d,proxy.convert2(new GenericsService2.Value(3.14f)).getValue(),0.00001); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testClient() throws Exception { Hello serviceImpl=new Hello(); try (EndpointImpl ep=new EndpointImpl(getBus(),serviceImpl,(String)null)){ ep.publish("local://localhost:9090/hello"); QName serviceName=new QName("http://service.jaxws.cxf.apache.org/","HelloService"); QName portName=new QName("http://service.jaxws.cxf.apache.org/","HelloPort"); ServiceImpl service=new ServiceImpl(getBus(),(URL)null,serviceName,null); service.addPort(portName,"http://schemas.xmlsoap.org/soap/","local://localhost:9090/hello"); HelloInterface proxy=service.getPort(portName,HelloInterface.class,new LoggingFeature()); Client client=ClientProxy.getClient(proxy); boolean found=false; for ( Interceptor i : client.getOutInterceptors()) { if (i instanceof LoggingOutInterceptor) { found=true; } } assertTrue(found); assertEquals("Get the wrong result","hello",proxy.sayHi("hello")); String[] strInput=new String[2]; strInput[0]="Hello"; strInput[1]="Bonjour"; String[] strings=proxy.getStringArray(strInput); assertEquals(strings.length,2); assertEquals(strings[0],"HelloHello"); assertEquals(strings[1],"BonjourBonjour"); List listInput=new ArrayList(); listInput.add("Hello"); listInput.add("Bonjour"); List list=proxy.getStringList(listInput); assertEquals(list.size(),2); assertEquals(list.get(0),"HelloHello"); assertEquals(list.get(1),"BonjourBonjour"); List result=proxy.getGreetings(); assertEquals(2,result.size()); } }

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testException() throws Exception { Hello serviceImpl=new Hello(); try (EndpointImpl ep=new EndpointImpl(getBus(),serviceImpl,(String)null)){ ep.publish("local://localhost:9090/hello"); ep.getServer().getEndpoint().getInInterceptors().add(new LoggingInInterceptor()); ep.getServer().getEndpoint().getOutInterceptors().add(new LoggingOutInterceptor()); QName serviceName=new QName("http://service.jaxws.cxf.apache.org/","HelloService"); QName portName=new QName("http://service.jaxws.cxf.apache.org/","HelloPort"); ServiceImpl service=new ServiceImpl(getBus(),(URL)null,serviceName,null); service.addPort(portName,"http://schemas.xmlsoap.org/soap/","local://localhost:9090/hello"); HelloInterface proxy=service.getPort(portName,HelloInterface.class); ClientProxy.getClient(proxy).getInFaultInterceptors().add(new LoggingInInterceptor()); ClientProxy.getClient(proxy).getInInterceptors().add(new LoggingInInterceptor()); try { proxy.addNumbers(1,-2); fail("should throw AddNumbersException"); } catch ( AddNumbersException e) { assertEquals(e.getInfo(),"Sum is less than 0."); } try { proxy.addNumbers(1,99); fail("should throw AddNumbersSubException"); } catch ( AddNumbersSubException e) { assertEquals(e.getSubInfo(),"Sum is 100"); } catch ( AddNumbersException e) { fail("should throw AddNumbersSubException"); } try (AutoCloseable c=(AutoCloseable)proxy){ assertEquals("Result = 2",proxy.addNumbers(1,1)); } try { proxy.addNumbers(1,1); fail("Proxy should be closed"); } catch ( IllegalStateException t) { } } }

InternalCallVerifier EqualityVerifier 
@Test public void testArrayAndList() throws Exception { ArrayServiceImpl serviceImpl=new ArrayServiceImpl(); try (EndpointImpl ep=new EndpointImpl(getBus(),serviceImpl,(String)null)){ ep.publish("local://localhost:9090/array"); ep.getServer().getEndpoint().getInInterceptors().add(new LoggingInInterceptor()); ep.getServer().getEndpoint().getOutInterceptors().add(new LoggingOutInterceptor()); QName serviceName=new QName("http://service.jaxws.cxf.apache.org/","ArrayService"); QName portName=new QName("http://service.jaxws.cxf.apache.org/","ArrayPort"); ServiceImpl service=new ServiceImpl(getBus(),(URL)null,serviceName,null); service.addPort(portName,"http://schemas.xmlsoap.org/soap/","local://localhost:9090/array"); ArrayService proxy=service.getPort(portName,ArrayService.class); String[] arrayOut=proxy.arrayOutput(); assertEquals(arrayOut.length,3); assertEquals(arrayOut[0],"string1"); assertEquals(arrayOut[1],"string2"); assertEquals(arrayOut[2],"string3"); String[] arrayIn=new String[3]; arrayIn[0]="string1"; arrayIn[1]="string2"; arrayIn[2]="string3"; assertEquals(proxy.arrayInput(arrayIn),"string1string2string3"); arrayOut=proxy.arrayInputAndOutput(arrayIn); assertEquals(arrayOut.length,3); assertEquals(arrayOut[0],"string11"); assertEquals(arrayOut[1],"string22"); assertEquals(arrayOut[2],"string33"); List listOut=proxy.listOutput(); assertEquals(listOut.size(),3); assertEquals(listOut.get(0),"string1"); assertEquals(listOut.get(1),"string2"); assertEquals(listOut.get(2),"string3"); List listIn=new ArrayList(); listIn.add("list1"); listIn.add("list2"); listIn.add("list3"); assertEquals(proxy.listInput(listIn),"list1list2list3"); } }

Class: org.apache.cxf.jaxws.CodeFirstWSDLTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testWSDL1() throws Exception { Definition d=createService(Hello2.class); QName serviceName=new QName("http://service.jaxws.cxf.apache.org/","Hello2Service"); javax.wsdl.Service service=d.getService(serviceName); assertNotNull(service); QName portName=new QName("http://service.jaxws.cxf.apache.org/","Hello2Port"); javax.wsdl.Port port=service.getPort(portName.getLocalPart()); assertNotNull(port); QName portTypeName=new QName("http://service.jaxws.cxf.apache.org/","HelloInterface"); javax.wsdl.PortType portType=d.getPortType(portTypeName); assertNotNull(portType); assertEquals(5,portType.getOperations().size()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testWSDL2() throws Exception { Definition d=createService(Hello3.class); QName serviceName=new QName("http://mynamespace.com/","MyService"); javax.wsdl.Service service=d.getService(serviceName); assertNotNull(service); QName portName=new QName("http://mynamespace.com/","MyPort"); javax.wsdl.Port port=service.getPort(portName.getLocalPart()); assertNotNull(port); QName portTypeName=new QName("http://service.jaxws.cxf.apache.org/","HelloInterface"); javax.wsdl.PortType portType=d.getPortType(portTypeName); assertNotNull(portType); assertEquals(5,portType.getOperations().size()); }

Class: org.apache.cxf.jaxws.EndpointImplTest

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testEndpointServiceConstructor() throws Exception { GreeterImpl greeter=new GreeterImpl(); JaxWsServiceFactoryBean serviceFactory=new JaxWsServiceFactoryBean(); serviceFactory.setBus(getBus()); serviceFactory.setInvoker(new BeanInvoker(greeter)); serviceFactory.setServiceClass(GreeterImpl.class); try (EndpointImpl endpoint=new EndpointImpl(getBus(),greeter,new JaxWsServerFactoryBean(serviceFactory))){ WebServiceContext ctx=greeter.getContext(); assertNull(ctx); try { String address="http://localhost:8080/test"; endpoint.publish(address); } catch ( IllegalArgumentException ex) { assertTrue(ex.getCause() instanceof BusException); assertEquals("BINDING_INCOMPATIBLE_ADDRESS_EXC",((BusException)ex.getCause()).getCode()); } ctx=greeter.getContext(); assertNotNull(ctx); } }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testWSAnnoWithoutWSDLLocationInSEI() throws Exception { HelloImpl hello=new HelloImpl(); JaxWsServiceFactoryBean serviceFactory=new JaxWsServiceFactoryBean(); serviceFactory.setBus(getBus()); serviceFactory.setInvoker(new BeanInvoker(hello)); serviceFactory.setServiceClass(HelloImpl.class); try (EndpointImpl endpoint=new EndpointImpl(getBus(),hello,new JaxWsServerFactoryBean(serviceFactory))){ try { String address="http://localhost:8080/test"; endpoint.publish(address); } catch ( IllegalArgumentException ex) { assertTrue(ex.getCause() instanceof BusException); assertEquals("BINDING_INCOMPATIBLE_ADDRESS_EXC",((BusException)ex.getCause()).getCode()); } } }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testAddWSAFeature() throws Exception { GreeterImpl greeter=new GreeterImpl(); JaxWsServiceFactoryBean serviceFactory=new JaxWsServiceFactoryBean(); serviceFactory.setBus(getBus()); serviceFactory.setInvoker(new BeanInvoker(greeter)); serviceFactory.setServiceClass(GreeterImpl.class); try (EndpointImpl endpoint=new EndpointImpl(getBus(),greeter,new JaxWsServerFactoryBean(serviceFactory))){ endpoint.getFeatures().add(new WSAddressingFeature()); try { String address="http://localhost:8080/test"; endpoint.publish(address); } catch ( IllegalArgumentException ex) { assertTrue(ex.getCause() instanceof BusException); assertEquals("BINDING_INCOMPATIBLE_ADDRESS_EXC",((BusException)ex.getCause()).getCode()); } assertTrue(serviceFactory.getFeatures().size() == 1); assertTrue(serviceFactory.getFeatures().get(0) instanceof WSAddressingFeature); } }

EqualityVerifier 
@Test public void testSOAPBindingOnMethodWithRPC(){ HelloWrongAnnotation hello=new HelloWrongAnnotation(); JaxWsServiceFactoryBean serviceFactory=new JaxWsServiceFactoryBean(); serviceFactory.setBus(getBus()); serviceFactory.setInvoker(new BeanInvoker(hello)); serviceFactory.setServiceClass(HelloWrongAnnotation.class); try { new EndpointImpl(getBus(),hello,new JaxWsServerFactoryBean(serviceFactory)).close(); } catch ( Exception e) { String expeced="Method [sayHi] processing error: SOAPBinding can not on method with RPC style"; assertEquals(expeced,e.getMessage()); } }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testJaxWsaFeature() throws Exception { HelloWsa greeter=new HelloWsa(); JaxWsServiceFactoryBean serviceFactory=new JaxWsServiceFactoryBean(); serviceFactory.setBus(getBus()); serviceFactory.setInvoker(new BeanInvoker(greeter)); serviceFactory.setServiceClass(HelloWsa.class); try (EndpointImpl endpoint=new EndpointImpl(getBus(),greeter,new JaxWsServerFactoryBean(serviceFactory))){ try { String address="http://localhost:8080/test"; endpoint.publish(address); } catch ( IllegalArgumentException ex) { assertTrue(ex.getCause() instanceof BusException); assertEquals("BINDING_INCOMPATIBLE_ADDRESS_EXC",((BusException)ex.getCause()).getCode()); } assertEquals(1,serviceFactory.getFeatures().size()); assertTrue(serviceFactory.getFeatures().get(0) instanceof WSAddressingFeature); } }

UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testEndpoint() throws Exception { String address="http://localhost:8080/test"; GreeterImpl greeter=new GreeterImpl(); try (EndpointImpl endpoint=new EndpointImpl(getBus(),greeter,(String)null)){ WebServiceContext ctx=greeter.getContext(); assertNull(ctx); try { endpoint.publish(address); } catch ( IllegalArgumentException ex) { assertTrue(ex.getCause() instanceof BusException); assertEquals("BINDING_INCOMPATIBLE_ADDRESS_EXC",((BusException)ex.getCause()).getCode()); } ctx=greeter.getContext(); assertNotNull(ctx); try { endpoint.publish(address); fail("republished an already published endpoint."); } catch ( IllegalStateException e) { } try { endpoint.setMetadata(new ArrayList(0)); fail("set metadata on an already published endpoint."); } catch ( IllegalStateException e) { } } }

UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testEndpointStop() throws Exception { String address="http://localhost:8080/test"; GreeterImpl greeter=new GreeterImpl(); try (EndpointImpl endpoint=new EndpointImpl(getBus(),greeter,(String)null)){ WebServiceContext ctx=greeter.getContext(); assertNull(ctx); try { endpoint.publish(address); } catch ( IllegalArgumentException ex) { assertTrue(ex.getCause() instanceof BusException); assertEquals("BINDING_INCOMPATIBLE_ADDRESS_EXC",((BusException)ex.getCause()).getCode()); } ctx=greeter.getContext(); assertNotNull(ctx); assertTrue(endpoint.isPublished()); endpoint.stop(); assertFalse(endpoint.isPublished()); try { endpoint.publish(address); fail("stopped endpoint restarted."); } catch ( IllegalStateException e) { } } }

Class: org.apache.cxf.jaxws.EndpointReferenceTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testEndpointReferenceGetPort() throws Exception { BusFactory.setDefaultBus(getBus()); GreeterImpl greeter1=new GreeterImpl(); try (EndpointImpl endpoint=new EndpointImpl(getBus(),greeter1,(String)null)){ endpoint.publish("http://localhost:8080/test"); InputStream is=getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml"); Document doc=StaxUtils.read(is); DOMSource erXML=new DOMSource(doc); EndpointReference endpointReference=EndpointReference.readFrom(erXML); WebServiceFeature[] wfs=new WebServiceFeature[]{}; Greeter greeter=endpointReference.getPort(Greeter.class,wfs); String response=greeter.greetMe("John"); assertEquals("Hello John",response); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testServiceGetPortUsingEndpointReference() throws Exception { BusFactory.setDefaultBus(getBus()); GreeterImpl greeter1=new GreeterImpl(); try (EndpointImpl endpoint=new EndpointImpl(getBus(),greeter1,(String)null)){ endpoint.publish("http://localhost:8080/test"); javax.xml.ws.Service s=javax.xml.ws.Service.create(new QName("http://apache.org/hello_world_soap_http","SoapPort")); InputStream is=getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml"); Document doc=StaxUtils.read(is); DOMSource erXML=new DOMSource(doc); EndpointReference endpointReference=EndpointReference.readFrom(erXML); WebServiceFeature[] wfs=new WebServiceFeature[]{}; Greeter greeter=s.getPort(endpointReference,Greeter.class,wfs); String response=greeter.greetMe("John"); assertEquals("Hello John",response); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testProviderGetPort() throws Exception { BusFactory.setDefaultBus(getBus()); GreeterImpl greeter1=new GreeterImpl(); try (EndpointImpl endpoint=new EndpointImpl(getBus(),greeter1,(String)null)){ endpoint.publish("http://localhost:8080/test"); ProviderImpl provider=new ProviderImpl(); InputStream is=getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml"); Document doc=StaxUtils.read(is); DOMSource erXML=new DOMSource(doc); EndpointReference endpointReference=EndpointReference.readFrom(erXML); WebServiceFeature[] wfs=new WebServiceFeature[]{}; Greeter greeter=provider.getPort(endpointReference,Greeter.class,wfs); String response=greeter.greetMe("John"); assertEquals("Hello John",response); } }

Class: org.apache.cxf.jaxws.GreeterTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testEndpoint() throws Exception { ReflectionServiceFactoryBean bean=new JaxWsServiceFactoryBean(); URL resource=getClass().getResource("/wsdl/hello_world.wsdl"); assertNotNull(resource); bean.setWsdlURL(resource.toString()); bean.setBus(bus); bean.setServiceClass(GreeterImpl.class); GreeterImpl greeter=new GreeterImpl(); BeanInvoker invoker=new BeanInvoker(greeter); Service service=bean.create(); assertEquals("SOAPService",service.getName().getLocalPart()); assertEquals("http://apache.org/hello_world_soap_http",service.getName().getNamespaceURI()); ServerFactoryBean svr=new ServerFactoryBean(); svr.setBus(bus); svr.setServiceFactory(bean); svr.setInvoker(invoker); svr.create(); Node response=invoke("http://localhost:9000/SoapContext/SoapPort",LocalTransportFactory.TRANSPORT_ID,"GreeterMessage.xml"); assertEquals(1,greeter.getInvocationCount()); assertNotNull(response); addNamespace("h","http://apache.org/hello_world_soap_http/types"); assertValid("/s:Envelope/s:Body",response); assertValid("//h:sayHiResponse",response); }

Class: org.apache.cxf.jaxws.HeaderTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testInvocation() throws Exception { JaxWsServiceFactoryBean bean=new JaxWsServiceFactoryBean(); Bus bus=getBus(); bean.setBus(bus); bean.setServiceClass(TestHeaderImpl.class); Service service=bean.create(); OperationInfo op=service.getServiceInfos().get(0).getInterface().getOperation(new QName(service.getName().getNamespaceURI(),"testHeader5")); assertNotNull(op); List parts=op.getInput().getMessageParts(); assertEquals(1,parts.size()); MessagePartInfo part=parts.get(0); assertNotNull(part.getTypeClass()); assertEquals(TestHeader5.class,part.getTypeClass()); parts=op.getOutput().getMessageParts(); assertEquals(2,parts.size()); part=parts.get(1); assertNotNull(part.getTypeClass()); assertEquals(TestHeader5ResponseBody.class,part.getTypeClass()); part=parts.get(0); assertNotNull(part.getTypeClass()); assertEquals(TestHeader5.class,part.getTypeClass()); ServerFactoryBean svr=new ServerFactoryBean(); svr.setBus(bus); svr.setServiceFactory(bean); svr.setServiceBean(new TestHeaderImpl()); svr.setAddress("http://localhost:9104/SoapHeaderContext/SoapHeaderPort"); svr.setBindingConfig(new JaxWsSoapBindingConfiguration(bean)); svr.create(); Node response=invoke("http://localhost:9104/SoapHeaderContext/SoapHeaderPort",LocalTransportFactory.TRANSPORT_ID,"testHeader5.xml"); assertNotNull(response); assertNoFault(response); addNamespace("t","http://apache.org/header_test/types"); assertValid("//s:Header/t:testHeader5",response); }

Class: org.apache.cxf.jaxws.JAXWSMethodInvokerTest

UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testFaultHeadersCopy() throws Throwable { ExceptionService serviceObject=new ExceptionService(); Method serviceMethod=ExceptionService.class.getMethod("invoke",new Class[]{}); Exchange ex=new ExchangeImpl(); prepareInMessage(ex,true); Message msg=new MessageImpl(); SoapMessage outMessage=new SoapMessage(msg); ex.setOutMessage(outMessage); JAXWSMethodInvoker jaxwsMethodInvoker=prepareJAXWSMethodInvoker(ex,serviceObject,serviceMethod); try { jaxwsMethodInvoker.invoke(ex,new MessageContentsList(new Object[]{})); fail("Expected fault"); } catch ( Fault fault) { Message outMsg=ex.getOutMessage(); Assert.assertNotNull(outMsg); @SuppressWarnings("unchecked") List
headers=(List
)outMsg.get(Header.HEADER_LIST); Assert.assertEquals(1,headers.size()); Assert.assertEquals(TEST_HEADER_NAME,headers.get(0).getName()); } }

InternalCallVerifier EqualityVerifier 
@Test public void testFactoryBeans() throws Throwable { Exchange ex=EasyMock.createMock(Exchange.class); EasyMock.reset(factory); factory.create(ex); EasyMock.expectLastCall().andReturn(target); EasyMock.replay(factory); JAXWSMethodInvoker jaxwsMethodInvoker=new JAXWSMethodInvoker(factory); Object object=jaxwsMethodInvoker.getServiceObject(ex); assertEquals("the target object and service object should be equal ",object,target); EasyMock.verify(factory); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testProviderInterpretNullAsOneway() throws Throwable { NullableProviderService serviceObject=new NullableProviderService(); Method serviceMethod=NullableProviderService.class.getMethod("invoke",new Class[]{Source.class}); Exchange ex=new ExchangeImpl(); Message inMessage=new MessageImpl(); inMessage.setInterceptorChain(new PhaseInterceptorChain(new TreeSet())); ex.setInMessage(inMessage); inMessage.setExchange(ex); inMessage.put(Message.REQUESTOR_ROLE,Boolean.TRUE); JAXWSMethodInvoker jaxwsMethodInvoker=prepareJAXWSMethodInvoker(ex,serviceObject,serviceMethod); ex.setOneWay(false); MessageContentsList obj=(MessageContentsList)jaxwsMethodInvoker.invoke(ex,new MessageContentsList(new Object[]{new StreamSource()})); assertEquals(1,obj.size()); assertNotNull(obj.get(0)); assertFalse(ex.isOneWay()); ex.setOneWay(true); obj=(MessageContentsList)jaxwsMethodInvoker.invoke(ex,new MessageContentsList(new Object[]{new StreamSource()})); assertNull(obj); assertTrue(ex.isOneWay()); ex.setOneWay(false); serviceObject.setNullable(true); obj=(MessageContentsList)jaxwsMethodInvoker.invoke(ex,new MessageContentsList(new Object[]{new StreamSource()})); assertNull(obj); assertTrue(ex.isOneWay()); ex.setOneWay(false); serviceObject.setNullable(true); inMessage.put("jaxws.provider.interpretNullAsOneway",Boolean.FALSE); obj=(MessageContentsList)jaxwsMethodInvoker.invoke(ex,new MessageContentsList(new Object[]{new StreamSource()})); assertEquals(1,obj.size()); assertNull(obj.get(0)); assertFalse(ex.isOneWay()); ex.setOneWay(false); serviceObject.setNullable(true); inMessage.put("jaxws.provider.interpretNullAsOneway",Boolean.TRUE); obj=(MessageContentsList)jaxwsMethodInvoker.invoke(ex,new MessageContentsList(new Object[]{new StreamSource()})); assertNull(obj); assertTrue(ex.isOneWay()); }

Class: org.apache.cxf.jaxws.JaxWsClientTest

APIUtilityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testRequestContextPutAndRemoveEcho() throws Exception { URL url=getClass().getResource("/wsdl/hello_world.wsdl"); javax.xml.ws.Service s=javax.xml.ws.Service.create(url,serviceName); final Greeter handler=s.getPort(portName,Greeter.class); Map requestContext=((BindingProvider)handler).getRequestContext(); requestContext.put(JaxWsClientProxy.THREAD_LOCAL_REQUEST_CONTEXT,Boolean.TRUE); requestContext=((BindingProvider)handler).getRequestContext(); final String key="Hi"; requestContext.put(key,"ho"); final Object[] result=new Object[2]; Thread t=new Thread(){ public void run(){ Map requestContext=((BindingProvider)handler).getRequestContext(); result[0]=requestContext.get(key); requestContext.remove(key); result[1]=requestContext.get(key); } } ; t.start(); t.join(); assertEquals("thread sees the put","ho",result[0]); assertNull("thread did not remove the put",result[1]); assertEquals("main thread does not see removal","ho",requestContext.get(key)); }

UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testEndpoint() throws Exception { ReflectionServiceFactoryBean bean=new JaxWsServiceFactoryBean(); URL resource=getClass().getResource("/wsdl/hello_world.wsdl"); assertNotNull(resource); bean.setWsdlURL(resource.toString()); bean.setBus(getBus()); bean.setServiceClass(GreeterImpl.class); GreeterImpl greeter=new GreeterImpl(); BeanInvoker invoker=new BeanInvoker(greeter); bean.setInvoker(invoker); Service service=bean.create(); String namespace="http://apache.org/hello_world_soap_http"; EndpointInfo ei=service.getServiceInfos().get(0).getEndpoint(new QName(namespace,"SoapPort")); JaxWsEndpointImpl endpoint=new JaxWsEndpointImpl(getBus(),service,ei); ClientImpl client=new ClientImpl(getBus(),endpoint); BindingOperationInfo bop=ei.getBinding().getOperation(new QName(namespace,"sayHi")); assertNotNull(bop); bop=bop.getUnwrappedOperation(); assertNotNull(bop); MessagePartInfo part=bop.getOutput().getMessageParts().get(0); assertEquals(0,part.getIndex()); d.setMessageObserver(new MessageReplayObserver("sayHiResponse.xml")); Object ret[]=client.invoke(bop,new Object[]{"hi"},null); assertNotNull(ret); assertEquals("Wrong number of return objects",1,ret.length); bop=ei.getBinding().getOperation(new QName(namespace,"testDocLitFault")); bop=bop.getUnwrappedOperation(); d.setMessageObserver(new MessageReplayObserver("testDocLitFault.xml")); try { client.invoke(bop,new Object[]{"BadRecordLitFault"},null); fail("Should have returned a fault!"); } catch ( BadRecordLitFault fault) { assertEquals("foo",fault.getFaultInfo().trim()); assertEquals("Hadrian did it.",fault.getMessage()); } try { client.getEndpoint().getOutInterceptors().add(new NestedFaultThrower()); client.getEndpoint().getOutInterceptors().add(new FaultThrower()); client.invoke(bop,new Object[]{"BadRecordLitFault"},null); fail("Should have returned a fault!"); } catch ( Fault fault) { assertEquals(true,fault.getMessage().indexOf("Foo") >= 0); } }

APIUtilityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testRequestContextPutAndRemoveEchoDispatch() throws Exception { URL url=getClass().getResource("/wsdl/hello_world.wsdl"); javax.xml.ws.Service s=javax.xml.ws.Service.create(url,serviceName); final Dispatch disp=s.createDispatch(portName,DOMSource.class,javax.xml.ws.Service.Mode.PAYLOAD); Map requestContext=disp.getRequestContext(); requestContext.put(JaxWsClientProxy.THREAD_LOCAL_REQUEST_CONTEXT,Boolean.TRUE); requestContext=disp.getRequestContext(); final String key="Hi"; requestContext.put(key,"ho"); final Object[] result=new Object[2]; Thread t=new Thread(){ public void run(){ Map requestContext=disp.getRequestContext(); result[0]=requestContext.get(key); requestContext.remove(key); result[1]=requestContext.get(key); } } ; t.start(); t.join(); assertEquals("thread sees the put","ho",result[0]); assertNull("thread did not remove the put",result[1]); assertEquals("main thread does not see removal","ho",requestContext.get(key)); }

InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testClientProxyFactory(){ JaxWsProxyFactoryBean cf=new JaxWsProxyFactoryBean(); cf.setAddress("http://localhost:9000/test"); Greeter greeter=cf.create(Greeter.class); Greeter greeter2=(Greeter)cf.create(); Greeter greeter3=(Greeter)cf.create(); Client c=(Client)greeter; Client c2=(Client)greeter2; Client c3=(Client)greeter3; assertNotSame(c,c2); assertNotSame(c,c3); assertNotSame(c3,c2); assertNotSame(c.getEndpoint(),c2.getEndpoint()); assertNotSame(c.getEndpoint(),c3.getEndpoint()); assertNotSame(c3.getEndpoint(),c2.getEndpoint()); c3.getInInterceptors(); ((BindingProvider)greeter).getRequestContext().put("test","manny"); ((BindingProvider)greeter2).getRequestContext().put("test","moe"); ((BindingProvider)greeter3).getRequestContext().put("test","jack"); assertEquals("manny",((BindingProvider)greeter).getRequestContext().get("test")); assertEquals("moe",((BindingProvider)greeter2).getRequestContext().get("test")); assertEquals("jack",((BindingProvider)greeter3).getRequestContext().get("test")); }

APIUtilityVerifier BranchVerifier UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testRequestContext() throws Exception { URL url=getClass().getResource("/wsdl/hello_world.wsdl"); javax.xml.ws.Service s=javax.xml.ws.Service.create(url,serviceName); Greeter greeter=s.getPort(portName,Greeter.class); InvocationHandler handler=Proxy.getInvocationHandler(greeter); BindingProvider bp=null; if (handler instanceof BindingProvider) { bp=(BindingProvider)handler; Map requestContext=bp.getRequestContext(); String reqAddr=(String)requestContext.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY); assertEquals("the address get from requestContext is not equal",address,reqAddr); } else { fail("can't get the requset context"); } }

Class: org.apache.cxf.jaxws.JaxWsServerFactoryBeanTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testJaxbExtraClass(){ JaxWsServerFactoryBean sf=new JaxWsServerFactoryBean(); sf.setBus(getBus()); sf.setAddress("http://localhost:9000/test"); sf.setServiceClass(Hello.class); sf.setStart(false); Map props=sf.getProperties(); if (props == null) { props=new HashMap(); } props.put("jaxb.additionalContextClasses",new Class[]{DescriptionType.class,DisplayNameType.class}); sf.setProperties(props); Server server=sf.create(); assertNotNull(server); Class[] extraClass=((JAXBDataBinding)sf.getServiceFactory().getDataBinding()).getExtraClass(); assertEquals(extraClass.length,2); assertEquals(extraClass[0],DescriptionType.class); assertEquals(extraClass[1],DisplayNameType.class); }

Class: org.apache.cxf.jaxws.SEIWithJAXBAnnoTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testXMLList() throws Exception { AddNumbersImpl serviceImpl=new AddNumbersImpl(); Endpoint.publish("local://localhost:9000/Hello",serviceImpl); JaxWsProxyFactoryBean factory=new JaxWsProxyFactoryBean(); factory.setBus(SpringBusFactory.getDefaultBus()); factory.setServiceClass(AddNumbers.class); factory.setAddress(address); AddNumbers proxy=(AddNumbers)factory.create(); StringWriter strWriter=new StringWriter(); LoggingOutInterceptor log=new LoggingOutInterceptor(new PrintWriter(strWriter)); ClientProxy.getClient(proxy).getOutInterceptors().add(log); List args=new ArrayList(); args.add("str1"); args.add("str2"); args.add("str3"); List result=proxy.addNumbers(args); String expected="str1 str2 str3"; assertTrue("Client does not use the generated wrapper class to marshal request parameters",strWriter.toString().indexOf(expected) > -1); assertEquals("Get the wrong result",100,(int)result.get(0)); }

Class: org.apache.cxf.jaxws.SOAPBindingTest

APIUtilityVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testRoles() throws Exception { URL wsdl1=getClass().getResource("/wsdl/calculator.wsdl"); assertNotNull(wsdl1); ServiceImpl service=new ServiceImpl(getBus(),wsdl1,SERVICE_1,ServiceImpl.class); CalculatorPortType cal=service.getPort(PORT_1,CalculatorPortType.class); BindingProvider bindingProvider=(BindingProvider)cal; assertTrue(bindingProvider.getBinding() instanceof SOAPBinding); SOAPBinding binding=(SOAPBinding)bindingProvider.getBinding(); assertNotNull(binding.getRoles()); assertEquals(2,binding.getRoles().size()); assertTrue(binding.getRoles().contains(Soap12.getInstance().getNextRole())); assertTrue(binding.getRoles().contains(Soap12.getInstance().getUltimateReceiverRole())); String myrole="http://myrole"; Set roles=new HashSet(); roles.add(myrole); binding.setRoles(roles); assertNotNull(binding.getRoles()); assertEquals(3,binding.getRoles().size()); assertTrue(binding.getRoles().contains(myrole)); assertTrue(binding.getRoles().contains(Soap12.getInstance().getNextRole())); assertTrue(binding.getRoles().contains(Soap12.getInstance().getUltimateReceiverRole())); roles.add(Soap12.getInstance().getNoneRole()); try { binding.setRoles(roles); fail("did not throw exception"); } catch ( WebServiceException e) { } }

Class: org.apache.cxf.jaxws.ServiceImplTest

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testPorts(){ URL wsdl1=getClass().getResource("/wsdl/calculator.wsdl"); assertNotNull(wsdl1); ServiceImpl service=new ServiceImpl(getBus(),wsdl1,SERVICE_1,ServiceImpl.class); Iterator iter=service.getPorts(); assertNotNull(iter); assertTrue(iter.hasNext()); assertEquals(PORT_1,iter.next()); assertFalse(iter.hasNext()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testJAXBCachedOnRepeatGetPort(){ System.gc(); System.gc(); URL wsdl1=getClass().getResource("/wsdl/calculator.wsdl"); assertNotNull(wsdl1); ServiceImpl service=new ServiceImpl(getBus(),wsdl1,SERVICE_1,ServiceImpl.class); CalculatorPortType cal1=service.getPort(PORT_1,CalculatorPortType.class); assertNotNull(cal1); ClientProxy cp=(ClientProxy)Proxy.getInvocationHandler(cal1); JAXBDataBinding db1=(JAXBDataBinding)cp.getClient().getEndpoint().getService().getDataBinding(); assertNotNull(db1); System.gc(); System.gc(); System.gc(); System.gc(); CalculatorPortType cal2=service.getPort(PORT_1,CalculatorPortType.class); assertNotNull(cal2); cp=(ClientProxy)Proxy.getInvocationHandler(cal2); JAXBDataBinding db2=(JAXBDataBinding)cp.getClient().getEndpoint().getService().getDataBinding(); assertNotNull(db2); assertEquals("got cached JAXBContext",db1.getContext(),db2.getContext()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testHandlerResolver(){ URL wsdl1=getClass().getResource("/wsdl/calculator.wsdl"); assertNotNull(wsdl1); ServiceImpl service=new ServiceImpl(getBus(),wsdl1,SERVICE_1,ServiceImpl.class); TestHandlerResolver resolver=new TestHandlerResolver(); assertNull(resolver.getPortInfo()); service.setHandlerResolver(resolver); CalculatorPortType cal=service.getPort(PORT_1,CalculatorPortType.class); assertNotNull(cal); PortInfo info=resolver.getPortInfo(); assertNotNull(info); assertEquals(SERVICE_1,info.getServiceName()); assertEquals(PORT_1,info.getPortName()); assertEquals(SOAPBinding.SOAP12HTTP_BINDING,info.getBindingID()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testServiceImpl() throws Exception { SOAPService service=new SOAPService(); Greeter proxy=service.getSoapPort(); Client client=ClientProxy.getClient(proxy); assertEquals("bar",client.getEndpoint().get("foo")); assertNotNull("expected ConduitSelector",client.getConduitSelector()); assertTrue("unexpected ConduitSelector",client.getConduitSelector() instanceof NullConduitSelector); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test @SuppressWarnings("unchecked") public void testGetSOAP12BindingIDFromWSDL() throws Exception { QName serviceName=new QName("http://apache.org/hello_world_soap12_http","SOAPService"); URL wsdlURL=getClass().getResource("/wsdl/hello_world_soap12.wsdl"); ServiceImpl seviceImpl=new ServiceImpl(this.getBus(),wsdlURL,serviceName,org.apache.hello_world_soap12_http.Greeter.class); Field f=seviceImpl.getClass().getDeclaredField("portInfos"); f.setAccessible(true); Map portInfoMap=(Map)f.get(seviceImpl); assertEquals(portInfoMap.values().iterator().next().getBindingID(),SOAPBinding.SOAP12HTTP_BINDING); }

Class: org.apache.cxf.jaxws.ServiceModelUtilsTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetOperationInputPartNamesRpc() throws Exception { getService(getClass().getResource("/wsdl/hello_world_rpc_lit.wsdl"),RPCLitGreeterImpl.class,new QName("http://apache.org/hello_world_rpclit","SoapPortRPCLit")); BindingOperationInfo operation=ServiceModelUtil.getOperation(message.getExchange(),"greetMe"); assertNotNull(operation); List names=ServiceModelUtil.getOperationInputPartNames(operation.getOperationInfo()); assertNotNull(names); assertEquals(1,names.size()); assertEquals("in",names.get(0)); operation=ServiceModelUtil.getOperation(message.getExchange(),"sayHi"); assertNotNull(operation); names=ServiceModelUtil.getOperationInputPartNames(operation.getOperationInfo()); assertNotNull(names); assertEquals(0,names.size()); operation=ServiceModelUtil.getOperation(message.getExchange(),"greetUs"); assertNotNull(operation); names=ServiceModelUtil.getOperationInputPartNames(operation.getOperationInfo()); assertNotNull(names); assertEquals(2,names.size()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetOperationInputPartNamesWrapped2() throws Exception { getService(getClass().getResource("/wsdl/calculator.wsdl"),CalculatorImpl.class,new QName("http://apache.org/cxf/calculator","CalculatorPort")); BindingOperationInfo operation=ServiceModelUtil.getOperation(message.getExchange(),"add"); assertNotNull(operation); List names=ServiceModelUtil.getOperationInputPartNames(operation.getOperationInfo()); assertNotNull(names); assertEquals(2,names.size()); assertEquals("arg0",names.get(0)); assertEquals("arg1",names.get(1)); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetOperationInputPartNamesBare() throws Exception { getService(getClass().getResource("/wsdl/hello_world_xml_bare.wsdl"),org.apache.hello_world_xml_http.bare.GreeterImpl.class,new QName("http://apache.org/hello_world_xml_http/bare","XMLPort")); BindingOperationInfo operation=ServiceModelUtil.getOperation(message.getExchange(),"greetMe"); assertNotNull(operation); List names=ServiceModelUtil.getOperationInputPartNames(operation.getOperationInfo()); assertNotNull(names); assertEquals(1,names.size()); assertEquals("requestType",names.get(0)); operation=ServiceModelUtil.getOperation(message.getExchange(),"sayHi"); assertNotNull(operation); names=ServiceModelUtil.getOperationInputPartNames(operation.getOperationInfo()); assertNotNull(names); assertEquals(0,names.size()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetOperationInputPartNamesWrapped() throws Exception { getService(getClass().getResource("/wsdl/hello_world.wsdl"),GreeterImpl.class,new QName("http://apache.org/hello_world_soap_http","SoapPort")); BindingOperationInfo operation=ServiceModelUtil.getOperation(message.getExchange(),"greetMe"); assertNotNull(operation); List names=ServiceModelUtil.getOperationInputPartNames(operation.getOperationInfo()); assertNotNull(names); assertEquals(1,names.size()); assertEquals("requestType",names.get(0)); operation=ServiceModelUtil.getOperation(message.getExchange(),"sayHi"); assertNotNull(operation); names=ServiceModelUtil.getOperationInputPartNames(operation.getOperationInfo()); assertNotNull(names); assertEquals(0,names.size()); }

Class: org.apache.cxf.jaxws.context.WrappedAttachmentsTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testCreateAndModify(){ Map content=new HashMap(); content.put("att-1",new DataHandler(new ByteArrayDataSource("Hello world!".getBytes(),"text/plain"))); content.put("att-2",new DataHandler(new ByteArrayDataSource("Hola mundo!".getBytes(),"text/plain"))); WrappedAttachments attachments=new WrappedAttachments(content); Attachment att3=new AttachmentImpl("att-3",new DataHandler(new ByteArrayDataSource("Bonjour tout le monde!".getBytes(),"text/plain"))); assertEquals(2,attachments.size()); assertFalse(attachments.isEmpty()); attachments.add(att3); assertEquals(3,attachments.size()); attachments.add(att3); assertEquals(3,attachments.size()); attachments.remove(att3); assertEquals(2,attachments.size()); Attachment attx=attachments.iterator().next(); attachments.remove(attx); assertEquals(1,attachments.size()); Attachment[] atts=attachments.toArray(new Attachment[attachments.size()]); assertEquals(1,atts.length); assertEquals("att-1".equals(attx.getId()) ? "att-2" : "att-1",atts[0].getId()); attachments.clear(); assertTrue(attachments.isEmpty()); assertTrue(content.isEmpty()); }

Class: org.apache.cxf.jaxws.context.WrappedMessageContextTest

BranchVerifier UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testPutAndGetJaxwsAttachments() throws Exception { WrappedMessageContext context=new WrappedMessageContext(new HashMap(),null,Scope.APPLICATION); DataHandler dh1=new DataHandler(new ByteArrayDataSource("Hello world!".getBytes(),"text/plain")); DataHandler dh2=new DataHandler(new ByteArrayDataSource("Hola mundo!".getBytes(),"text/plain")); DataHandler dh3=new DataHandler(new ByteArrayDataSource("Bonjour tout le monde!".getBytes(),"text/plain")); Map jattachments=new HashMap(); context.put(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS,jattachments); jattachments.put("attachment-1",dh1); Set cattachments=CastUtils.cast((Set)context.get(Message.ATTACHMENTS)); assertNotNull(cattachments); assertEquals(1,cattachments.size()); jattachments.put("attachment-2",dh2); assertEquals(2,cattachments.size()); AttachmentImpl ca=new AttachmentImpl("attachment-3",dh3); ca.setHeader("X-test","true"); cattachments.add(ca); assertEquals(3,jattachments.size()); assertEquals(3,cattachments.size()); for ( Attachment a : cattachments) { if ("attachment-1".equals(a.getId())) { assertEquals("Hello world!",a.getDataHandler().getContent()); } else if ("attachment-2".equals(a.getId())) { assertEquals("Hola mundo!",a.getDataHandler().getContent()); } else if ("attachment-3".equals(a.getId())) { assertEquals("Bonjour tout le monde!",a.getDataHandler().getContent()); assertEquals("true",a.getHeader("X-test")); } else { fail("unknown attachment"); } } }

Class: org.apache.cxf.jaxws.dispatch.DispatchOpTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testResolveOperationWithSourceAndWSA() throws Exception { ServiceImpl service=new ServiceImpl(getBus(),getClass().getResource(wsdlResource),serviceName,null,new AddressingFeature()); Dispatch disp=service.createDispatch(portName,Source.class,Service.Mode.PAYLOAD); disp.getRequestContext().put(MessageContext.WSDL_OPERATION,operationName); disp.getRequestContext().put(Dispatch.ENDPOINT_ADDRESS_PROPERTY,address); d.setMessageObserver(new MessageReplayObserver(responseResource)); BindingOperationVerifier bov=new BindingOperationVerifier(); ((DispatchImpl)disp).getClient().getOutInterceptors().add(bov); Document doc=StaxUtils.read(getResourceAsStream(requestResource)); DOMSource source=new DOMSource(doc); Source res=disp.invoke(source); assertNotNull(res); BindingOperationInfo boi=bov.getBindingOperationInfo(); assertNotNull(boi); assertEquals(operationName,boi.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testResolveOperationWithSource() throws Exception { ServiceImpl service=new ServiceImpl(getBus(),getClass().getResource(wsdlResource),serviceName,null); Dispatch disp=service.createDispatch(portName,Source.class,Service.Mode.PAYLOAD); disp.getRequestContext().put(MessageContext.WSDL_OPERATION,operationName); disp.getRequestContext().put(Dispatch.ENDPOINT_ADDRESS_PROPERTY,address); d.setMessageObserver(new MessageReplayObserver(responseResource)); BindingOperationVerifier bov=new BindingOperationVerifier(); ((DispatchImpl)disp).getClient().getOutInterceptors().add(bov); Document doc=StaxUtils.read(getResourceAsStream(requestResource)); DOMSource source=new DOMSource(doc); Source res=disp.invoke(source); assertNotNull(res); BindingOperationInfo boi=bov.getBindingOperationInfo(); assertNotNull(boi); assertEquals(operationName,boi.getName()); }

Class: org.apache.cxf.jaxws.dispatch.DispatchTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testFindOperationWithSource() throws Exception { ServiceImpl service=new ServiceImpl(getBus(),getClass().getResource("/wsdl/hello_world.wsdl"),serviceName,null); Dispatch disp=service.createDispatch(portName,Source.class,Service.Mode.MESSAGE); disp.getRequestContext().put(Dispatch.ENDPOINT_ADDRESS_PROPERTY,address); disp.getRequestContext().put("find.dispatch.operation",Boolean.TRUE); d.setMessageObserver(new MessageReplayObserver("/org/apache/cxf/jaxws/sayHiResponse.xml")); BindingOperationVerifier bov=new BindingOperationVerifier(); ((DispatchImpl)disp).getClient().getOutInterceptors().add(bov); Document doc=StaxUtils.read(getResourceAsStream("/org/apache/cxf/jaxws/sayHi2.xml")); DOMSource source=new DOMSource(doc); Source res=disp.invoke(source); assertNotNull(res); BindingOperationInfo boi=bov.getBindingOperationInfo(); assertNotNull(boi); assertEquals(new QName("http://apache.org/hello_world_soap_http","sayHi"),boi.getName()); }

Class: org.apache.cxf.jaxws.handler.AbstractProtocolHandlerInterceptorTest

EqualityVerifier 
@Test public void testInterceptSuccess(){ expect(message.getExchange()).andReturn(exchange).anyTimes(); expect(exchange.get(HandlerChainInvoker.class)).andReturn(invoker).anyTimes(); expect(invoker.invokeProtocolHandlers(eq(false),isA(MessageContext.class))).andReturn(true); expect(exchange.getOutMessage()).andReturn(message); control.replay(); IIOPHandlerInterceptor pi=new IIOPHandlerInterceptor(binding); assertEquals("unexpected phase","user-protocol",pi.getPhase()); pi.handleMessage(message); }

Class: org.apache.cxf.jaxws.handler.AnnotationHandlerChainBuilderTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testFindHandlerChainAnnotationPerPortServiceBinding(){ HandlerTestImpl handlerTestImpl=new HandlerTestImpl(); AnnotationHandlerChainBuilder chainBuilder=new AnnotationHandlerChainBuilder(); QName portQName=new QName("namespacedoesntsupportyet","SoapPort1"); QName serviceQName=new QName("namespacedoesntsupportyet","SoapService1"); String bindingID="http://schemas.xmlsoap.org/wsdl/soap/http"; @SuppressWarnings("rawtypes") List handlers=chainBuilder.buildHandlerChainFromClass(handlerTestImpl.getClass(),portQName,serviceQName,bindingID); assertNotNull(handlers); assertEquals(5,handlers.size()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testFindHandlerChainAnnotationPerPortServiceBindingWildcard(){ HandlerTestImpl handlerTestImpl=new HandlerTestImpl(); AnnotationHandlerChainBuilder chainBuilder=new AnnotationHandlerChainBuilder(); QName portQName=new QName("http://apache.org/handler_test","SoapPortWildcard"); QName serviceQName=new QName("http://apache.org/handler_test","SoapServiceWildcard"); String bindingID="BindingUnknow"; @SuppressWarnings("rawtypes") List handlers=chainBuilder.buildHandlerChainFromClass(handlerTestImpl.getClass(),portQName,serviceQName,bindingID); assertNotNull(handlers); assertEquals(7,handlers.size()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testFindHandlerChainAnnotation(){ HandlerTestImpl handlerTestImpl=new HandlerTestImpl(); AnnotationHandlerChainBuilder chainBuilder=new AnnotationHandlerChainBuilder(); @SuppressWarnings("rawtypes") List handlers=chainBuilder.buildHandlerChainFromClass(handlerTestImpl.getClass(),null,null,null); assertNotNull(handlers); assertEquals(9,handlers.size()); assertEquals(TestLogicalHandler.class,handlers.get(0).getClass()); assertEquals(TestLogicalHandler.class,handlers.get(1).getClass()); assertEquals(TestLogicalHandler.class,handlers.get(2).getClass()); assertEquals(TestLogicalHandler.class,handlers.get(3).getClass()); assertEquals(TestLogicalHandler.class,handlers.get(4).getClass()); assertEquals(TestLogicalHandler.class,handlers.get(5).getClass()); assertEquals(TestLogicalHandler.class,handlers.get(6).getClass()); assertEquals(TestProtocolHandler.class,handlers.get(7).getClass()); assertEquals(TestProtocolHandler.class,handlers.get(8).getClass()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testFindHandlerChainAnnotationPerPortServiceBindingNegative(){ HandlerTestImpl handlerTestImpl=new HandlerTestImpl(); AnnotationHandlerChainBuilder chainBuilder=new AnnotationHandlerChainBuilder(); QName portQName=new QName("namespacedoesntsupportyet","SoapPortUnknown"); QName serviceQName=new QName("namespacedoesntsupportyet","SoapServiceUnknown"); String bindingID="BindingUnknow"; @SuppressWarnings("rawtypes") List handlers=chainBuilder.buildHandlerChainFromClass(handlerTestImpl.getClass(),portQName,serviceQName,bindingID); assertNotNull(handlers); assertEquals(3,handlers.size()); }

Class: org.apache.cxf.jaxws.handler.HandlerChainBuilderTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier PublicFieldVerifier HybridVerifier 
@Test public void testBuilderCallsInit(){ List hc=createHandlerChainType(); hc.remove(3); hc.remove(2); hc.remove(1); PortComponentHandlerType h=hc.get(0); List params=h.getInitParam(); ParamValueType p=new ParamValueType(); CString pName=new CString(); pName.setValue("foo"); p.setParamName(pName); XsdStringType pValue=new XsdStringType(); pValue.setValue("1"); p.setParamValue(pValue); params.add(p); p=new ParamValueType(); pName=new CString(); pName.setValue("bar"); p.setParamName(pName); pValue=new XsdStringType(); pValue.setValue("2"); p.setParamValue(pValue); params.add(p); List chain=builder.buildHandlerChainFromConfiguration(hc); assertEquals(1,chain.size()); TestLogicalHandler tlh=(TestLogicalHandler)chain.get(0); assertTrue(tlh.initCalled); Map cfg=tlh.config; assertNotNull(tlh.config); assertEquals(2,cfg.keySet().size()); assertEquals("1",cfg.get("foo")); assertEquals("2",cfg.get("bar")); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBuildHandlerChainFromConfiguration(){ List hc=createHandlerChainType(); List chain=builder.buildHandlerChainFromConfiguration(hc); assertNotNull(chain); assertEquals(4,chain.size()); assertEquals(TestLogicalHandler.class,chain.get(0).getClass()); assertEquals(TestLogicalHandler.class,chain.get(1).getClass()); assertEquals(TestProtocolHandler.class,chain.get(2).getClass()); assertEquals(TestProtocolHandler.class,chain.get(3).getClass()); TestLogicalHandler tlh=(TestLogicalHandler)chain.get(0); assertTrue(!tlh.initCalled); assertNull(tlh.config); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier PublicFieldVerifier HybridVerifier 
@Test public void testBuilderCallsInitWithNoInitParamValues(){ List hc=createHandlerChainType(); hc.remove(3); hc.remove(2); hc.remove(1); PortComponentHandlerType h=hc.get(0); List params=h.getInitParam(); ParamValueType p=new ParamValueType(); CString pName=new CString(); pName.setValue("foo"); p.setParamName(pName); params.add(p); List chain=builder.buildHandlerChainFromConfiguration(hc); assertEquals(1,chain.size()); TestLogicalHandler tlh=(TestLogicalHandler)chain.get(0); assertTrue(tlh.initCalled); Map cfg=tlh.config; assertNotNull(tlh.config); assertEquals(1,cfg.keySet().size()); }

UtilityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBuilderCannotLoadHandlerClass(){ List hc=createHandlerChainType(); hc.remove(3); hc.remove(2); hc.remove(1); FullyQualifiedClassType type=new FullyQualifiedClassType(); type.setValue("no.such.class"); hc.get(0).setHandlerClass(type); try { builder.buildHandlerChainFromConfiguration(hc); fail("did not get expected exception"); } catch ( WebServiceException ex) { assertNotNull(ex.getCause()); assertEquals(ClassNotFoundException.class,ex.getCause().getClass()); } }

Class: org.apache.cxf.jaxws.handler.HandlerChainInvokerTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testHandleMessageReturnsFalseWithNoResponseExpected(){ assertFalse(invoker.faultRaised()); logicalHandlers[0].setHandleMessageRet(true); logicalHandlers[1].setHandleMessageRet(true); logicalHandlers[2].setHandleMessageRet(false); logicalHandlers[3].setHandleMessageRet(true); invoker.setResponseExpected(false); boolean continueProcessing=true; continueProcessing=invoker.invokeLogicalHandlers(false,lmc); assertFalse(continueProcessing); assertEquals(1,logicalHandlers[0].getHandleMessageCount()); assertEquals(1,logicalHandlers[1].getHandleMessageCount()); assertEquals(1,logicalHandlers[2].getHandleMessageCount()); assertEquals(0,logicalHandlers[3].getHandleMessageCount()); assertTrue(logicalHandlers[0].getInvokeOrderOfHandleMessage() < logicalHandlers[1].getInvokeOrderOfHandleMessage()); assertTrue(logicalHandlers[1].getInvokeOrderOfHandleMessage() < logicalHandlers[2].getInvokeOrderOfHandleMessage()); assertEquals(1,logicalHandlers[0].getCloseCount()); assertEquals(1,logicalHandlers[1].getCloseCount()); assertEquals(1,logicalHandlers[2].getCloseCount()); assertEquals(0,logicalHandlers[3].getCloseCount()); assertEquals(0,logicalHandlers[0].getHandleFaultCount()); assertEquals(0,logicalHandlers[1].getHandleFaultCount()); assertEquals(0,logicalHandlers[2].getHandleFaultCount()); assertEquals(0,logicalHandlers[3].getHandleFaultCount()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testMEPComplete(){ invoker.invokeLogicalHandlers(false,lmc); invoker.invokeProtocolHandlers(false,pmc); assertEquals(8,invoker.getInvokedHandlers().size()); invoker.mepComplete(message); assertTrue("close not invoked on logicalHandlers",logicalHandlers[0].isCloseInvoked()); assertTrue("close not invoked on logicalHandlers",logicalHandlers[1].isCloseInvoked()); assertTrue("close not invoked on protocolHandlers",protocolHandlers[0].isCloseInvoked()); assertTrue("close not invoked on protocolHandlers",protocolHandlers[1].isCloseInvoked()); assertTrue("incorrect invocation order of close",protocolHandlers[1].getInvokeOrderOfClose() < protocolHandlers[0].getInvokeOrderOfClose()); assertTrue("incorrect invocation order of close",protocolHandlers[0].getInvokeOrderOfClose() < logicalHandlers[1].getInvokeOrderOfClose()); assertTrue("incorrect invocation order of close",logicalHandlers[1].getInvokeOrderOfClose() < logicalHandlers[0].getInvokeOrderOfClose()); }

UtilityVerifier BooleanVerifier InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testHandleMessageThrowsProtocolExceptionWithResponseExpected(){ assertFalse(invoker.faultRaised()); ProtocolException pe=new ProtocolException("banzai"); logicalHandlers[2].setException(pe); invoker.setRequestor(true); try { invoker.setLogicalMessageContext(lmc); invoker.invokeLogicalHandlers(false,lmc); fail("did not get expected exception"); } catch ( ProtocolException e) { assertEquals("banzai",e.getMessage()); } assertTrue(invoker.faultRaised()); assertSame(pe,invoker.getFault()); assertFalse((Boolean)lmc.get(LogicalMessageContext.MESSAGE_OUTBOUND_PROPERTY)); assertEquals(1,logicalHandlers[0].getHandleMessageCount()); assertEquals(1,logicalHandlers[1].getHandleMessageCount()); assertEquals(1,logicalHandlers[2].getHandleMessageCount()); assertEquals(0,logicalHandlers[3].getHandleMessageCount()); assertTrue(logicalHandlers[1].getInvokeOrderOfHandleMessage() < logicalHandlers[2].getInvokeOrderOfHandleMessage()); assertEquals(1,logicalHandlers[0].getHandleFaultCount()); assertEquals(1,logicalHandlers[1].getHandleFaultCount()); assertEquals(0,logicalHandlers[2].getHandleFaultCount()); assertEquals(0,logicalHandlers[2].getHandleFaultCount()); assertTrue(logicalHandlers[1].getInvokeOrderOfHandleFault() < logicalHandlers[0].getInvokeOrderOfHandleFault()); assertEquals(1,logicalHandlers[0].getCloseCount()); assertEquals(1,logicalHandlers[1].getCloseCount()); assertEquals(1,logicalHandlers[2].getCloseCount()); assertEquals(0,logicalHandlers[3].getCloseCount()); }

UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testHandleFaultThrowsRuntimeException(){ ProtocolException pe=new ProtocolException("banzai"); RuntimeException re=new RuntimeException("banzai"); logicalHandlers[2].setException(pe); logicalHandlers[1].setFaultException(re); invoker.setRequestor(true); boolean continueProcessing=false; try { continueProcessing=invoker.invokeLogicalHandlers(false,lmc); fail("did not get expected exception"); } catch ( RuntimeException e) { assertEquals("banzai",e.getMessage()); } assertFalse(continueProcessing); assertTrue(invoker.isClosed()); assertEquals(1,logicalHandlers[0].getHandleMessageCount()); assertEquals(1,logicalHandlers[1].getHandleMessageCount()); assertEquals(1,logicalHandlers[2].getHandleMessageCount()); assertEquals(0,logicalHandlers[3].getHandleMessageCount()); assertEquals(0,logicalHandlers[0].getHandleFaultCount()); assertEquals(1,logicalHandlers[1].getHandleFaultCount()); assertEquals(0,logicalHandlers[2].getHandleFaultCount()); assertEquals(1,logicalHandlers[0].getCloseCount()); assertEquals(1,logicalHandlers[1].getCloseCount()); assertEquals(1,logicalHandlers[2].getCloseCount()); assertEquals(0,logicalHandlers[3].getCloseCount()); assertTrue(logicalHandlers[2].getInvokeOrderOfClose() < logicalHandlers[1].getInvokeOrderOfClose()); assertTrue(logicalHandlers[1].getInvokeOrderOfClose() < logicalHandlers[0].getInvokeOrderOfClose()); }

UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testHandleFaultReturnsTrue(){ ProtocolException pe=new ProtocolException("banzai"); logicalHandlers[2].setException(pe); invoker.setRequestor(true); logicalHandlers[0].setHandleFaultRet(true); logicalHandlers[1].setHandleFaultRet(true); logicalHandlers[2].setHandleFaultRet(true); logicalHandlers[3].setHandleFaultRet(true); boolean continueProcessing=false; try { continueProcessing=invoker.invokeLogicalHandlers(false,lmc); fail("did not get expected exception"); } catch ( RuntimeException e) { assertEquals("banzai",e.getMessage()); } assertFalse(continueProcessing); assertEquals(1,logicalHandlers[0].getHandleMessageCount()); assertEquals(1,logicalHandlers[1].getHandleMessageCount()); assertEquals(1,logicalHandlers[2].getHandleMessageCount()); assertEquals(0,logicalHandlers[3].getHandleMessageCount()); assertEquals(1,logicalHandlers[0].getHandleFaultCount()); assertEquals(1,logicalHandlers[1].getHandleFaultCount()); assertEquals(0,logicalHandlers[2].getHandleFaultCount()); assertEquals(0,logicalHandlers[3].getHandleFaultCount()); assertTrue(logicalHandlers[1].getInvokeOrderOfHandleFault() < logicalHandlers[0].getInvokeOrderOfHandleFault()); assertEquals(1,logicalHandlers[0].getCloseCount()); assertEquals(1,logicalHandlers[1].getCloseCount()); assertEquals(1,logicalHandlers[2].getCloseCount()); assertEquals(0,logicalHandlers[3].getCloseCount()); }

UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testHandleFaultReturnsFalseOutbound(){ ProtocolException pe=new ProtocolException("banzai"); protocolHandlers[2].setException(pe); protocolHandlers[0].setHandleFaultRet(false); invoker.setRequestor(true); assertTrue(invoker.isOutbound()); boolean continueProcessing=true; invoker.setLogicalMessageContext(lmc); continueProcessing=invoker.invokeLogicalHandlers(false,lmc); assertTrue(continueProcessing); try { invoker.setProtocolMessageContext(pmc); continueProcessing=invoker.invokeProtocolHandlers(false,pmc); fail("did not get expected exception"); } catch ( ProtocolException e) { assertEquals("banzai",e.getMessage()); } assertFalse((Boolean)pmc.get(SOAPMessageContext.MESSAGE_OUTBOUND_PROPERTY)); assertFalse((Boolean)lmc.get(LogicalMessageContext.MESSAGE_OUTBOUND_PROPERTY)); assertTrue(invoker.isInbound()); assertEquals(1,logicalHandlers[0].getHandleMessageCount()); assertEquals(1,logicalHandlers[1].getHandleMessageCount()); assertEquals(1,logicalHandlers[2].getHandleMessageCount()); assertEquals(1,logicalHandlers[3].getHandleMessageCount()); assertEquals(1,protocolHandlers[0].getHandleMessageCount()); assertEquals(1,protocolHandlers[1].getHandleMessageCount()); assertEquals(1,protocolHandlers[2].getHandleMessageCount()); assertEquals(0,protocolHandlers[3].getHandleMessageCount()); assertTrue(logicalHandlers[3].getInvokeOrderOfHandleMessage() < protocolHandlers[0].getInvokeOrderOfHandleMessage()); assertTrue(protocolHandlers[1].getInvokeOrderOfHandleMessage() < protocolHandlers[2].getInvokeOrderOfHandleMessage()); assertEquals(1,logicalHandlers[0].getCloseCount()); assertEquals(1,logicalHandlers[1].getCloseCount()); assertEquals(1,logicalHandlers[2].getCloseCount()); assertEquals(1,logicalHandlers[3].getCloseCount()); assertEquals(1,protocolHandlers[0].getCloseCount()); assertEquals(1,protocolHandlers[1].getCloseCount()); assertEquals(1,protocolHandlers[2].getCloseCount()); assertEquals(0,protocolHandlers[3].getCloseCount()); assertTrue(protocolHandlers[2].getInvokeOrderOfClose() < protocolHandlers[1].getInvokeOrderOfClose()); assertTrue(protocolHandlers[0].getInvokeOrderOfClose() < logicalHandlers[3].getInvokeOrderOfClose()); assertEquals(0,logicalHandlers[0].getHandleFaultCount()); assertEquals(0,logicalHandlers[1].getHandleFaultCount()); assertEquals(0,logicalHandlers[2].getHandleFaultCount()); assertEquals(0,logicalHandlers[3].getHandleFaultCount()); assertEquals(1,protocolHandlers[0].getHandleFaultCount()); assertEquals(1,protocolHandlers[1].getHandleFaultCount()); assertEquals(0,protocolHandlers[2].getHandleFaultCount()); assertEquals(0,protocolHandlers[3].getHandleFaultCount()); assertTrue(protocolHandlers[2].getInvokeOrderOfHandleFault() < protocolHandlers[1].getInvokeOrderOfHandleFault()); }

APIUtilityVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testHandleMessageThrowsProtocolExceptionOutbound(){ message=new SoapMessage(message); lmc=new LogicalMessageContextImpl(message); pmc=new WrappedMessageContext(message); ProtocolException pe=new ProtocolException("banzai"); protocolHandlers[2].setException(pe); invoker.setRequestor(true); assertTrue(invoker.isOutbound()); boolean continueProcessing=true; invoker.setLogicalMessageContext(lmc); continueProcessing=invoker.invokeLogicalHandlers(false,lmc); assertTrue(continueProcessing); try { pmc=new SOAPMessageContextImpl(message); MessageFactory factory=MessageFactory.newInstance(); SOAPMessage soapMessage=factory.createMessage(); ((SOAPMessageContext)pmc).setMessage(soapMessage); } catch ( SOAPException e) { } try { invoker.setProtocolMessageContext(pmc); continueProcessing=invoker.invokeProtocolHandlers(false,pmc); fail("did not get expected exception"); } catch ( ProtocolException e) { assertEquals("banzai",e.getMessage()); } assertFalse((Boolean)pmc.get(SOAPMessageContext.MESSAGE_OUTBOUND_PROPERTY)); assertFalse((Boolean)lmc.get(LogicalMessageContext.MESSAGE_OUTBOUND_PROPERTY)); assertTrue(invoker.isInbound()); Source responseMessage=lmc.getMessage().getPayload(); assertTrue(getSourceAsString(responseMessage).indexOf("banzai") > -1); assertEquals(1,logicalHandlers[0].getHandleMessageCount()); assertEquals(1,logicalHandlers[1].getHandleMessageCount()); assertEquals(1,logicalHandlers[2].getHandleMessageCount()); assertEquals(1,logicalHandlers[3].getHandleMessageCount()); assertEquals(1,protocolHandlers[0].getHandleMessageCount()); assertEquals(1,protocolHandlers[1].getHandleMessageCount()); assertEquals(1,protocolHandlers[2].getHandleMessageCount()); assertEquals(0,protocolHandlers[3].getHandleMessageCount()); assertTrue(logicalHandlers[3].getInvokeOrderOfHandleMessage() < protocolHandlers[0].getInvokeOrderOfHandleMessage()); assertTrue(protocolHandlers[1].getInvokeOrderOfHandleMessage() < protocolHandlers[2].getInvokeOrderOfHandleMessage()); assertEquals(1,logicalHandlers[0].getCloseCount()); assertEquals(1,logicalHandlers[1].getCloseCount()); assertEquals(1,logicalHandlers[2].getCloseCount()); assertEquals(1,logicalHandlers[3].getCloseCount()); assertEquals(1,protocolHandlers[0].getCloseCount()); assertEquals(1,protocolHandlers[1].getCloseCount()); assertEquals(1,protocolHandlers[2].getCloseCount()); assertEquals(0,protocolHandlers[3].getCloseCount()); assertTrue(protocolHandlers[2].getInvokeOrderOfClose() < protocolHandlers[1].getInvokeOrderOfClose()); assertTrue(protocolHandlers[0].getInvokeOrderOfClose() < logicalHandlers[3].getInvokeOrderOfClose()); assertEquals(1,logicalHandlers[0].getHandleFaultCount()); assertEquals(1,logicalHandlers[1].getHandleFaultCount()); assertEquals(1,logicalHandlers[2].getHandleFaultCount()); assertEquals(1,logicalHandlers[3].getHandleFaultCount()); assertEquals(1,protocolHandlers[0].getHandleFaultCount()); assertEquals(1,protocolHandlers[1].getHandleFaultCount()); assertEquals(0,protocolHandlers[2].getHandleFaultCount()); assertEquals(0,protocolHandlers[3].getHandleFaultCount()); assertTrue(protocolHandlers[0].getInvokeOrderOfHandleFault() < logicalHandlers[3].getInvokeOrderOfHandleFault()); assertTrue(protocolHandlers[2].getInvokeOrderOfHandleFault() < protocolHandlers[1].getInvokeOrderOfHandleFault()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testLogicalHandlerInboundProcessingStoppedResponseExpected(){ assertEquals(0,logicalHandlers[0].getHandleMessageCount()); assertEquals(0,logicalHandlers[1].getHandleMessageCount()); invoker.setInbound(); logicalHandlers[1].setHandleMessageRet(false); boolean ret=invoker.invokeLogicalHandlers(false,lmc); assertFalse(invoker.isClosed()); assertEquals(false,ret); assertEquals(0,logicalHandlers[0].getHandleMessageCount()); assertEquals(1,logicalHandlers[1].getHandleMessageCount()); assertTrue(invoker.isOutbound()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testHandlerPartitioning(){ assertEquals(HANDLER_COUNT,invoker.getLogicalHandlers().size()); for ( Handler h : invoker.getLogicalHandlers()) { assertTrue(h instanceof LogicalHandler); } assertEquals(HANDLER_COUNT,invoker.getProtocolHandlers().size()); for ( Handler h : invoker.getProtocolHandlers()) { assertTrue(!(h instanceof LogicalHandler)); } }

UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testHandleFaultThrowsProtocolException(){ ProtocolException pe=new ProtocolException("banzai"); ProtocolException pe2=new ProtocolException("banzai2"); logicalHandlers[2].setException(pe); logicalHandlers[1].setFaultException(pe2); invoker.setRequestor(true); boolean continueProcessing=false; try { continueProcessing=invoker.invokeLogicalHandlers(false,lmc); fail("did not get expected exception"); } catch ( ProtocolException e) { assertEquals("banzai2",e.getMessage()); } assertFalse(continueProcessing); assertTrue(invoker.isClosed()); assertEquals(1,logicalHandlers[0].getHandleMessageCount()); assertEquals(1,logicalHandlers[1].getHandleMessageCount()); assertEquals(1,logicalHandlers[2].getHandleMessageCount()); assertEquals(0,logicalHandlers[3].getHandleMessageCount()); assertTrue(logicalHandlers[1].getInvokeOrderOfHandleMessage() < logicalHandlers[2].getInvokeOrderOfHandleMessage()); assertEquals(0,logicalHandlers[0].getHandleFaultCount()); assertEquals(1,logicalHandlers[1].getHandleFaultCount()); assertEquals(0,logicalHandlers[2].getHandleFaultCount()); assertEquals(1,logicalHandlers[0].getCloseCount()); assertEquals(1,logicalHandlers[1].getCloseCount()); assertEquals(1,logicalHandlers[2].getCloseCount()); assertEquals(0,logicalHandlers[3].getCloseCount()); assertTrue(logicalHandlers[2].getInvokeOrderOfClose() < logicalHandlers[1].getInvokeOrderOfClose()); assertTrue(logicalHandlers[1].getInvokeOrderOfClose() < logicalHandlers[0].getInvokeOrderOfClose()); }

UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testHandleMessageThrowsRuntimeExceptionWithResponseExpected(){ assertFalse(invoker.faultRaised()); RuntimeException re=new RuntimeException("banzai"); logicalHandlers[1].setException(re); invoker.setRequestor(true); try { invoker.invokeLogicalHandlers(false,lmc); fail("did not get expected exception"); } catch ( RuntimeException e) { assertEquals("banzai",e.getMessage()); } assertTrue(invoker.isClosed()); assertEquals(1,logicalHandlers[0].getHandleMessageCount()); assertEquals(1,logicalHandlers[1].getHandleMessageCount()); assertEquals(0,logicalHandlers[2].getHandleMessageCount()); assertEquals(0,logicalHandlers[3].getHandleMessageCount()); assertTrue(logicalHandlers[0].getInvokeOrderOfHandleMessage() < logicalHandlers[1].getInvokeOrderOfHandleMessage()); assertEquals(0,logicalHandlers[0].getHandleFaultCount()); assertEquals(0,logicalHandlers[1].getHandleFaultCount()); assertEquals(0,logicalHandlers[2].getHandleFaultCount()); assertEquals(0,logicalHandlers[3].getHandleFaultCount()); assertEquals(1,logicalHandlers[0].getCloseCount()); assertEquals(1,logicalHandlers[1].getCloseCount()); assertEquals(0,logicalHandlers[2].getCloseCount()); assertEquals(0,logicalHandlers[3].getCloseCount()); }

BooleanVerifier InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testHandleMessageThrowsProtocolExceptionWithNoResponseExpected(){ assertFalse(invoker.faultRaised()); ProtocolException pe=new ProtocolException("banzai"); logicalHandlers[2].setException(pe); invoker.setResponseExpected(false); invoker.setRequestor(true); try { invoker.invokeLogicalHandlers(false,lmc); } catch ( ProtocolException e) { assertEquals("banzai",e.getMessage()); } assertTrue(invoker.faultRaised()); assertSame(pe,invoker.getFault()); assertEquals(1,logicalHandlers[0].getHandleMessageCount()); assertEquals(1,logicalHandlers[1].getHandleMessageCount()); assertEquals(1,logicalHandlers[2].getHandleMessageCount()); assertEquals(0,logicalHandlers[3].getHandleMessageCount()); assertTrue(logicalHandlers[1].getInvokeOrderOfHandleMessage() < logicalHandlers[2].getInvokeOrderOfHandleMessage()); assertEquals(0,logicalHandlers[0].getHandleFaultCount()); assertEquals(0,logicalHandlers[1].getHandleFaultCount()); assertEquals(0,logicalHandlers[2].getHandleFaultCount()); assertEquals(0,logicalHandlers[3].getHandleFaultCount()); assertEquals(1,logicalHandlers[0].getCloseCount()); assertEquals(1,logicalHandlers[1].getCloseCount()); assertEquals(1,logicalHandlers[2].getCloseCount()); assertEquals(0,logicalHandlers[3].getCloseCount()); assertTrue(logicalHandlers[1].getInvokeOrderOfClose() < logicalHandlers[0].getInvokeOrderOfClose()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testInvokedAlreadyInvokedMixed(){ logicalHandlers[1].setHandleMessageRet(false); invoker.setInbound(); invoker.invokeProtocolHandlers(true,pmc); invoker.invokeLogicalHandlers(true,lmc); assertEquals(7,invoker.getInvokedHandlers().size()); assertTrue(invoker.getInvokedHandlers().contains(protocolHandlers[0])); assertTrue(invoker.getInvokedHandlers().contains(protocolHandlers[1])); assertEquals(0,logicalHandlers[0].getHandleMessageCount()); assertEquals(1,logicalHandlers[1].getHandleMessageCount()); logicalHandlers[1].setHandleMessageRet(true); invoker.invokeLogicalHandlers(true,lmc); invoker.invokeProtocolHandlers(true,pmc); assertEquals(2,protocolHandlers[0].getHandleMessageCount()); assertEquals(2,protocolHandlers[1].getHandleMessageCount()); assertEquals(1,logicalHandlers[1].getHandleMessageCount()); assertEquals(0,logicalHandlers[0].getHandleMessageCount()); assertEquals(2,protocolHandlers[0].getHandleMessageCount()); assertEquals(2,protocolHandlers[1].getHandleMessageCount()); }

UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testHandleFaultReturnsFalse(){ ProtocolException pe=new ProtocolException("banzai"); logicalHandlers[3].setException(pe); invoker.setRequestor(true); logicalHandlers[0].setHandleFaultRet(true); logicalHandlers[1].setHandleFaultRet(true); logicalHandlers[2].setHandleFaultRet(false); logicalHandlers[3].setHandleFaultRet(true); boolean continueProcessing=false; try { continueProcessing=invoker.invokeLogicalHandlers(false,lmc); fail("did not get expected exception"); } catch ( RuntimeException e) { assertEquals("banzai",e.getMessage()); } assertFalse(continueProcessing); assertEquals(1,logicalHandlers[0].getHandleMessageCount()); assertEquals(1,logicalHandlers[1].getHandleMessageCount()); assertEquals(1,logicalHandlers[2].getHandleMessageCount()); assertEquals(1,logicalHandlers[3].getHandleMessageCount()); assertEquals(0,logicalHandlers[0].getHandleFaultCount()); assertEquals(0,logicalHandlers[1].getHandleFaultCount()); assertEquals(1,logicalHandlers[2].getHandleFaultCount()); assertEquals(0,logicalHandlers[3].getHandleFaultCount()); assertEquals(1,logicalHandlers[0].getCloseCount()); assertEquals(1,logicalHandlers[1].getCloseCount()); assertEquals(1,logicalHandlers[2].getCloseCount()); assertEquals(1,logicalHandlers[3].getCloseCount()); assertTrue(logicalHandlers[3].getInvokeOrderOfClose() < logicalHandlers[2].getInvokeOrderOfClose()); assertTrue(logicalHandlers[2].getInvokeOrderOfClose() < logicalHandlers[1].getInvokeOrderOfClose()); assertTrue(logicalHandlers[1].getInvokeOrderOfClose() < logicalHandlers[0].getInvokeOrderOfClose()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testHandleMessageReturnsFalseWithResponseExpected(){ assertFalse(invoker.faultRaised()); logicalHandlers[0].setHandleMessageRet(true); logicalHandlers[1].setHandleMessageRet(true); logicalHandlers[2].setHandleMessageRet(false); logicalHandlers[3].setHandleMessageRet(true); invoker.setResponseExpected(true); boolean continueProcessing=true; invoker.setLogicalMessageContext(lmc); continueProcessing=invoker.invokeLogicalHandlers(false,lmc); assertFalse(continueProcessing); assertFalse((Boolean)lmc.get(LogicalMessageContext.MESSAGE_OUTBOUND_PROPERTY)); assertEquals(1,logicalHandlers[0].getHandleMessageCount()); assertEquals(1,logicalHandlers[1].getHandleMessageCount()); assertEquals(1,logicalHandlers[2].getHandleMessageCount()); assertEquals(0,logicalHandlers[3].getHandleMessageCount()); logicalHandlers[2].setHandleMessageRet(true); invoker.invokeLogicalHandlers(false,lmc); assertEquals(2,logicalHandlers[0].getHandleMessageCount()); assertEquals(2,logicalHandlers[1].getHandleMessageCount()); assertEquals(1,logicalHandlers[2].getHandleMessageCount()); assertEquals(0,logicalHandlers[3].getHandleMessageCount()); assertTrue(logicalHandlers[3].getInvokeOrderOfHandleMessage() < logicalHandlers[2].getInvokeOrderOfHandleMessage()); assertTrue(logicalHandlers[2].getInvokeOrderOfHandleMessage() < logicalHandlers[1].getInvokeOrderOfHandleMessage()); assertTrue(logicalHandlers[1].getInvokeOrderOfHandleMessage() < logicalHandlers[0].getInvokeOrderOfHandleMessage()); assertEquals(0,logicalHandlers[0].getCloseCount()); assertEquals(0,logicalHandlers[1].getCloseCount()); assertEquals(0,logicalHandlers[2].getCloseCount()); assertEquals(0,logicalHandlers[0].getHandleFaultCount()); assertEquals(0,logicalHandlers[1].getHandleFaultCount()); assertEquals(0,logicalHandlers[2].getHandleFaultCount()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testHandleMessageReturnsFalseOutbound(){ protocolHandlers[2].setHandleMessageRet(false); assertTrue(invoker.isOutbound()); boolean continueProcessing=true; invoker.setLogicalMessageContext(lmc); continueProcessing=invoker.invokeLogicalHandlers(false,lmc); invoker.setProtocolMessageContext(pmc); continueProcessing=invoker.invokeProtocolHandlers(false,pmc); assertFalse((Boolean)pmc.get(SOAPMessageContext.MESSAGE_OUTBOUND_PROPERTY)); assertFalse((Boolean)lmc.get(LogicalMessageContext.MESSAGE_OUTBOUND_PROPERTY)); assertTrue(invoker.isInbound()); assertFalse(continueProcessing); protocolHandlers[2].setHandleMessageRet(true); invoker.setProtocolMessageContext(pmc); continueProcessing=invoker.invokeProtocolHandlers(false,pmc); invoker.setLogicalMessageContext(lmc); continueProcessing=invoker.invokeLogicalHandlers(false,lmc); assertEquals(2,logicalHandlers[0].getHandleMessageCount()); assertEquals(2,logicalHandlers[1].getHandleMessageCount()); assertEquals(2,logicalHandlers[2].getHandleMessageCount()); assertEquals(2,logicalHandlers[3].getHandleMessageCount()); assertEquals(2,protocolHandlers[0].getHandleMessageCount()); assertEquals(2,protocolHandlers[1].getHandleMessageCount()); assertEquals(1,protocolHandlers[2].getHandleMessageCount()); assertEquals(0,protocolHandlers[3].getHandleMessageCount()); assertTrue(logicalHandlers[3].getInvokeOrderOfHandleMessage() < logicalHandlers[2].getInvokeOrderOfHandleMessage()); assertTrue(logicalHandlers[2].getInvokeOrderOfHandleMessage() < logicalHandlers[1].getInvokeOrderOfHandleMessage()); assertTrue(logicalHandlers[1].getInvokeOrderOfHandleMessage() < logicalHandlers[0].getInvokeOrderOfHandleMessage()); assertTrue(protocolHandlers[0].getInvokeOrderOfHandleMessage() < logicalHandlers[3].getInvokeOrderOfHandleMessage()); assertTrue(protocolHandlers[2].getInvokeOrderOfHandleMessage() < protocolHandlers[1].getInvokeOrderOfHandleMessage()); assertEquals(0,logicalHandlers[0].getCloseCount()); assertEquals(0,logicalHandlers[1].getCloseCount()); assertEquals(0,logicalHandlers[2].getCloseCount()); assertEquals(0,logicalHandlers[0].getHandleFaultCount()); assertEquals(0,logicalHandlers[1].getHandleFaultCount()); assertEquals(0,logicalHandlers[2].getHandleFaultCount()); assertEquals(0,protocolHandlers[0].getCloseCount()); assertEquals(0,protocolHandlers[1].getCloseCount()); assertEquals(0,protocolHandlers[2].getCloseCount()); assertEquals(0,protocolHandlers[0].getHandleFaultCount()); assertEquals(0,protocolHandlers[1].getHandleFaultCount()); assertEquals(0,protocolHandlers[2].getHandleFaultCount()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testInvokeHandlersInbound(){ invoker.setInbound(); assertTrue(invoker.isInbound()); checkProtocolHandlersInvoked(false); assertEquals(4,invoker.getInvokedHandlers().size()); assertTrue(invoker.isInbound()); checkLogicalHandlersInvoked(false,true); assertEquals(8,invoker.getInvokedHandlers().size()); assertTrue(invoker.isInbound()); assertFalse(invoker.isClosed()); assertTrue(logicalHandlers[0].getInvokeOrderOfHandleMessage() > logicalHandlers[1].getInvokeOrderOfHandleMessage()); assertTrue(logicalHandlers[1].getInvokeOrderOfHandleMessage() > protocolHandlers[0].getInvokeOrderOfHandleMessage()); assertTrue(protocolHandlers[0].getInvokeOrderOfHandleMessage() > protocolHandlers[1].getInvokeOrderOfHandleMessage()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testHandleMessageReturnsTrue(){ assertFalse(invoker.faultRaised()); logicalHandlers[0].setHandleMessageRet(true); logicalHandlers[1].setHandleMessageRet(true); logicalHandlers[2].setHandleMessageRet(true); logicalHandlers[3].setHandleMessageRet(true); boolean continueProcessing=true; continueProcessing=invoker.invokeLogicalHandlers(false,lmc); assertTrue(continueProcessing); assertEquals(1,logicalHandlers[0].getHandleMessageCount()); assertEquals(1,logicalHandlers[1].getHandleMessageCount()); assertEquals(1,logicalHandlers[2].getHandleMessageCount()); assertEquals(1,logicalHandlers[3].getHandleMessageCount()); assertTrue(logicalHandlers[0].getInvokeOrderOfHandleMessage() < logicalHandlers[1].getInvokeOrderOfHandleMessage()); assertTrue(logicalHandlers[1].getInvokeOrderOfHandleMessage() < logicalHandlers[2].getInvokeOrderOfHandleMessage()); assertTrue(logicalHandlers[2].getInvokeOrderOfHandleMessage() < logicalHandlers[3].getInvokeOrderOfHandleMessage()); assertEquals(0,logicalHandlers[0].getCloseCount()); assertEquals(0,logicalHandlers[1].getCloseCount()); assertEquals(0,logicalHandlers[2].getCloseCount()); assertEquals(0,logicalHandlers[3].getCloseCount()); assertEquals(0,logicalHandlers[0].getHandleFaultCount()); assertEquals(0,logicalHandlers[1].getHandleFaultCount()); assertEquals(0,logicalHandlers[2].getHandleFaultCount()); assertEquals(0,logicalHandlers[3].getHandleFaultCount()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testLogicalHandlerReturnFalseOutboundResponseExpected(){ assertEquals(0,logicalHandlers[0].getHandleMessageCount()); assertEquals(0,logicalHandlers[1].getHandleMessageCount()); assertEquals(0,logicalHandlers[2].getHandleMessageCount()); assertTrue(invoker.isOutbound()); logicalHandlers[1].setHandleMessageRet(false); boolean ret=invoker.invokeLogicalHandlers(false,lmc); assertEquals(false,ret); assertFalse(invoker.isClosed()); assertEquals(1,logicalHandlers[0].getHandleMessageCount()); assertEquals(1,logicalHandlers[1].getHandleMessageCount()); assertEquals(0,logicalHandlers[2].getHandleMessageCount()); assertTrue(invoker.isInbound()); logicalHandlers[1].setHandleMessageRet(true); ret=invoker.invokeLogicalHandlers(false,lmc); assertTrue(ret); assertFalse(invoker.isClosed()); assertEquals(2,logicalHandlers[0].getHandleMessageCount()); assertEquals(1,logicalHandlers[1].getHandleMessageCount()); assertEquals(0,logicalHandlers[2].getHandleMessageCount()); assertTrue(invoker.isInbound()); }

Class: org.apache.cxf.jaxws.handler.InitParamResourceResolverTest

InternalCallVerifier EqualityVerifier 
@Test public void testResolveString(){ String ret=resolver.resolve(STRING_PARAM,String.class); assertEquals("incorrect string value returned",STRING_VALUE,ret); }

Class: org.apache.cxf.jaxws.handler.LogicalHandlerInterceptorTest

EqualityVerifier 
@Test public void testInterceptSuccess(){ List> list=new ArrayList>(); list.add(new LogicalHandler(){ public void close( MessageContext arg0){ } public boolean handleFault( LogicalMessageContext arg0){ return true; } public boolean handleMessage( LogicalMessageContext arg0){ return true; } } ); @SuppressWarnings("rawtypes") List hList=CastUtils.cast(list); expect(binding.getHandlerChain()).andReturn(hList).anyTimes(); expect(invoker.getLogicalHandlers()).andReturn(list); expect(message.getExchange()).andReturn(exchange).anyTimes(); expect(message.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.TRUE).anyTimes(); expect(message.keySet()).andReturn(new TreeSet()).anyTimes(); expect(exchange.get(HandlerChainInvoker.class)).andReturn(invoker); expect(exchange.getOutMessage()).andReturn(message); expect(invoker.invokeLogicalHandlers(eq(true),isA(LogicalMessageContext.class))).andReturn(true); control.replay(); LogicalHandlerInInterceptor li=new LogicalHandlerInInterceptor(binding); assertEquals("unexpected phase","pre-protocol-frontend",li.getPhase()); li.handleMessage(message); control.verify(); }

Class: org.apache.cxf.jaxws.handler.LogicalMessageImplTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testGetPayloadOfJAXB() throws Exception { JAXBContext ctx=JAXBContext.newInstance(ObjectFactory.class); Message message=new MessageImpl(); Exchange e=new ExchangeImpl(); message.setExchange(e); LogicalMessageContextImpl lmci=new LogicalMessageContextImpl(message); JAXBElement el=new ObjectFactory().createAddNumbers(req); LogicalMessageImpl lmi=new LogicalMessageImpl(lmci); lmi.setPayload(el,ctx); Object obj=lmi.getPayload(ctx); assertTrue(obj instanceof JAXBElement); JAXBElement el2=(JAXBElement)obj; assertTrue(el2.getValue() instanceof AddNumbers); AddNumbers resp=(AddNumbers)el2.getValue(); assertEquals(req.getArg0(),resp.getArg0()); assertEquals(req.getArg1(),resp.getArg1()); }

Class: org.apache.cxf.jaxws.handler.soap.SOAPHandlerInterceptorTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testChangeSOAPHeaderInBound() throws Exception { @SuppressWarnings("rawtypes") List list=new ArrayList(); list.add(new SOAPHandler(){ public boolean handleMessage( SOAPMessageContext smc){ try { Boolean outboundProperty=(Boolean)smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (!outboundProperty.booleanValue()) { SOAPMessage message=smc.getMessage(); SOAPHeader soapHeader=message.getSOAPHeader(); Element headerElementNew=(Element)soapHeader.getFirstChild(); SoapVersion soapVersion=Soap11.getInstance(); Attr attr=headerElementNew.getOwnerDocument().createAttributeNS(soapVersion.getNamespace(),"SOAP-ENV:mustUnderstand"); attr.setValue("false"); headerElementNew.setAttributeNodeNS(attr); } } catch ( Exception e) { throw new Fault(e); } return true; } public boolean handleFault( SOAPMessageContext smc){ return true; } public Set getHeaders(){ return null; } public void close( MessageContext messageContext){ } } ); HandlerChainInvoker invoker=new HandlerChainInvoker(list); IMocksControl control=createNiceControl(); Binding binding=control.createMock(Binding.class); expect(binding.getHandlerChain()).andReturn(list).anyTimes(); Exchange exchange=control.createMock(Exchange.class); expect(exchange.get(HandlerChainInvoker.class)).andReturn(invoker).anyTimes(); expect(exchange.getOutMessage()).andReturn(null); SoapMessage message=new SoapMessage(new MessageImpl()); message.setExchange(exchange); XMLStreamReader reader=preparemXMLStreamReader("resources/greetMeRpcLitReq.xml"); message.setContent(XMLStreamReader.class,reader); Object[] headerInfo=prepareSOAPHeader(); message.setContent(Node.class,headerInfo[0]); Node node=((Element)headerInfo[1]).getFirstChild(); message.getHeaders().add(new Header(new QName(node.getNamespaceURI(),node.getLocalName()),node)); control.replay(); SOAPHandlerInterceptor li=new SOAPHandlerInterceptor(binding); li.handleMessage(message); control.verify(); SOAPMessage soapMessageNew=message.getContent(SOAPMessage.class); Element headerElementNew=DOMUtils.getFirstElement(soapMessageNew.getSOAPHeader()); SoapVersion soapVersion=Soap11.getInstance(); assertEquals("false",headerElementNew.getAttributeNS(soapVersion.getNamespace(),"mustUnderstand")); XMLStreamReader xmlReader=message.getContent(XMLStreamReader.class); QName qn=xmlReader.getName(); assertEquals("sendReceiveData",qn.getLocalPart()); Iterator
iter=message.getHeaders().iterator(); Element requiredHeader=null; while (iter.hasNext()) { Header localHdr=iter.next(); if (localHdr.getObject() instanceof Element) { Element elem=(Element)localHdr.getObject(); if (elem.getNamespaceURI().equals("http://apache.org/hello_world_rpclit/types") && elem.getLocalName().equals("header1")) { requiredHeader=(Element)localHdr.getObject(); break; } } } assertNotNull("Should have found header1",requiredHeader); assertEquals("false",requiredHeader.getAttributeNS(soapVersion.getNamespace(),"mustUnderstand")); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testChangeSOAPBodyOutBound() throws Exception { @SuppressWarnings("rawtypes") List list=new ArrayList(); list.add(new SOAPHandler(){ public boolean handleMessage( SOAPMessageContext smc){ Boolean outboundProperty=(Boolean)smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outboundProperty.booleanValue()) { try { smc.setMessage(prepareSOAPMessage("resources/greetMeRpcLitRespChanged.xml")); } catch ( Exception e) { throw new Fault(e); } } return true; } public boolean handleFault( SOAPMessageContext smc){ return true; } public Set getHeaders(){ return null; } public void close( MessageContext messageContext){ } } ); HandlerChainInvoker invoker=new HandlerChainInvoker(list); IMocksControl control=createNiceControl(); Binding binding=control.createMock(Binding.class); expect(binding.getHandlerChain()).andReturn(list).anyTimes(); Exchange exchange=control.createMock(Exchange.class); expect(exchange.get(HandlerChainInvoker.class)).andReturn(invoker).anyTimes(); SoapMessage message=new SoapMessage(new MessageImpl()); message.setExchange(exchange); expect(exchange.getOutMessage()).andReturn(message).anyTimes(); CachedStream originalEmptyOs=new CachedStream(); XMLStreamWriter writer=StaxUtils.createXMLStreamWriter(originalEmptyOs); message.setContent(XMLStreamWriter.class,writer); InterceptorChain chain=new PhaseInterceptorChain((new PhaseManagerImpl()).getOutPhases()); chain.add(new AbstractProtocolHandlerInterceptor(binding,Phase.MARSHAL){ public void handleMessage( SoapMessage message) throws Fault { try { XMLStreamWriter writer=message.getContent(XMLStreamWriter.class); SoapVersion soapVersion=Soap11.getInstance(); writer.setPrefix("soap",soapVersion.getNamespace()); writer.writeStartElement("soap",soapVersion.getEnvelope().getLocalPart(),soapVersion.getNamespace()); writer.writeNamespace("soap",soapVersion.getNamespace()); writer.writeEndElement(); writer.flush(); } catch ( Exception e) { } } } ); chain.add(new SOAPHandlerInterceptor(binding)); message.setInterceptorChain(chain); control.replay(); chain.doIntercept(message); control.verify(); writer.flush(); SOAPMessage resultedMessage=message.getContent(SOAPMessage.class); assertNotNull(resultedMessage); SOAPBody bodyNew=resultedMessage.getSOAPBody(); Iterator itNew=bodyNew.getChildElements(new QName("http://apache.org/hello_world_rpclit","sendReceiveDataResponse")); SOAPBodyElement bodyElementNew=(SOAPBodyElement)itNew.next(); Iterator outIt=bodyElementNew.getChildElements(new QName("http://apache.org/hello_world_rpclit/types","out")); Element outElement=(SOAPElement)outIt.next(); assertNotNull(outElement); Element elem3Element=DOMUtils.findAllElementsByTagNameNS(outElement,"http://apache.org/hello_world_rpclit/types","elem3").get(0); assertEquals("100",elem3Element.getTextContent()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetSOAPMessageInBound() throws Exception { @SuppressWarnings("rawtypes") List list=new ArrayList(); list.add(new SOAPHandler(){ public boolean handleMessage( SOAPMessageContext smc){ try { smc.getMessage(); } catch ( Exception e) { throw new Fault(e); } return true; } public boolean handleFault( SOAPMessageContext smc){ return true; } public Set getHeaders(){ return null; } public void close( MessageContext messageContext){ } } ); HandlerChainInvoker invoker=new HandlerChainInvoker(list); IMocksControl control=createNiceControl(); Binding binding=control.createMock(Binding.class); Exchange exchange=control.createMock(Exchange.class); expect(binding.getHandlerChain()).andReturn(list).anyTimes(); expect(exchange.get(HandlerChainInvoker.class)).andReturn(invoker).anyTimes(); expect(exchange.getOutMessage()).andReturn(null); SoapMessage message=new SoapMessage(new MessageImpl()); message.setExchange(exchange); XMLStreamReader reader=preparemXMLStreamReader("resources/greetMeRpcLitReq.xml"); message.setContent(XMLStreamReader.class,reader); control.replay(); SOAPHandlerInterceptor li=new SOAPHandlerInterceptor(binding); li.handleMessage(message); control.verify(); SOAPMessage soapMessageNew=message.getContent(SOAPMessage.class); SOAPBody bodyNew=soapMessageNew.getSOAPBody(); Iterator itNew=bodyNew.getChildElements(); SOAPBodyElement bodyElementNew=(SOAPBodyElement)itNew.next(); assertEquals("sendReceiveData",bodyElementNew.getLocalName()); XMLStreamReader xmlReader=message.getContent(XMLStreamReader.class); QName qn=xmlReader.getName(); assertEquals("sendReceiveData",qn.getLocalPart()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testChangeSOAPHeaderOutBound() throws Exception { @SuppressWarnings("rawtypes") List list=new ArrayList(); list.add(new SOAPHandler(){ public boolean handleMessage( SOAPMessageContext smc){ try { Boolean outboundProperty=(Boolean)smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outboundProperty.booleanValue()) { SOAPMessage message=smc.getMessage(); SOAPHeader soapHeader=message.getSOAPHeader(); Iterator it=soapHeader.getChildElements(new QName("http://apache.org/hello_world_rpclit/types","header1")); SOAPHeaderElement headerElementNew=(SOAPHeaderElement)it.next(); SoapVersion soapVersion=Soap11.getInstance(); Attr attr=headerElementNew.getOwnerDocument().createAttributeNS(soapVersion.getNamespace(),"SOAP-ENV:mustUnderstand"); attr.setValue("false"); headerElementNew.setAttributeNodeNS(attr); } } catch ( Exception e) { throw new Fault(e); } return true; } public boolean handleFault( SOAPMessageContext smc){ return true; } public Set getHeaders(){ return null; } public void close( MessageContext messageContext){ } } ); HandlerChainInvoker invoker=new HandlerChainInvoker(list); IMocksControl control=createNiceControl(); Binding binding=control.createMock(Binding.class); expect(binding.getHandlerChain()).andReturn(list).anyTimes(); Exchange exchange=control.createMock(Exchange.class); expect(exchange.get(HandlerChainInvoker.class)).andReturn(invoker).anyTimes(); SoapMessage message=new SoapMessage(new MessageImpl()); message.setExchange(exchange); expect(exchange.getOutMessage()).andReturn(message).anyTimes(); CachedStream originalEmptyOs=new CachedStream(); message.setContent(OutputStream.class,originalEmptyOs); InterceptorChain chain=new PhaseInterceptorChain((new PhaseManagerImpl()).getOutPhases()); chain.add(new AbstractProtocolHandlerInterceptor(binding,Phase.MARSHAL){ public void handleMessage( SoapMessage message) throws Fault { try { XMLStreamWriter writer=message.getContent(XMLStreamWriter.class); SoapVersion soapVersion=Soap11.getInstance(); writer.setPrefix("soap",soapVersion.getNamespace()); writer.writeStartElement("soap",soapVersion.getEnvelope().getLocalPart(),soapVersion.getNamespace()); writer.writeNamespace("soap",soapVersion.getNamespace()); Object[] headerInfo=prepareSOAPHeader(); StaxUtils.writeElement((Element)headerInfo[1],writer,true,false); writer.writeEndElement(); writer.flush(); } catch ( Exception e) { } } } ); chain.add(new SOAPHandlerInterceptor(binding)); message.setInterceptorChain(chain); control.replay(); chain.doIntercept(message); control.verify(); SOAPMessage soapMessageNew=message.getContent(SOAPMessage.class); SOAPHeader soapHeader=soapMessageNew.getSOAPHeader(); Iterator itNew=soapHeader.getChildElements(new QName("http://apache.org/hello_world_rpclit/types","header1")); SOAPHeaderElement headerElementNew=(SOAPHeaderElement)itNew.next(); SoapVersion soapVersion=Soap11.getInstance(); assertEquals("false",headerElementNew.getAttributeNS(soapVersion.getNamespace(),"mustUnderstand")); originalEmptyOs.close(); }

Class: org.apache.cxf.jaxws.header.HeaderClientServerTest

IterativeVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testHeaderPartBeforeBodyPart() throws Exception { URL wsdl=getClass().getResource("/wsdl/soapheader.wsdl"); assertNotNull(wsdl); SOAPHeaderService service=new SOAPHeaderService(wsdl,serviceName); assertNotNull(service); TestHeader proxy=service.getPort(portName,TestHeader.class); TestHeader6 in=new TestHeader6(); String val=new String(TestHeader6.class.getSimpleName()); Holder inoutHeader=new Holder(); for (int idx=0; idx < 1; idx++) { val+=idx; in.setRequestType(val); inoutHeader.value=new TestHeader3(); TestHeader6Response returnVal=proxy.testHeaderPartBeforeBodyPart(inoutHeader,in); assertNotNull(returnVal); assertNull(returnVal.getResponseType()); assertEquals(val,inoutHeader.value.getRequestType()); in.setRequestType(null); inoutHeader.value.setRequestType(val); returnVal=proxy.testHeaderPartBeforeBodyPart(inoutHeader,in); assertNotNull(returnVal); assertEquals(val,returnVal.getResponseType()); assertNull(inoutHeader.value.getRequestType()); } }

IterativeVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testInOutHeader() throws Exception { URL wsdl=getClass().getResource("/wsdl/soapheader.wsdl"); assertNotNull(wsdl); SOAPHeaderService service=new SOAPHeaderService(wsdl,serviceName); assertNotNull(service); TestHeader proxy=service.getPort(portName,TestHeader.class); try { TestHeader3 in=new TestHeader3(); String val=new String(TestHeader3.class.getSimpleName()); Holder inoutHeader=new Holder(); for (int idx=0; idx < 2; idx++) { val+=idx; in.setRequestType(val); inoutHeader.value=new TestHeader3(); TestHeader3Response returnVal=proxy.testHeader3(in,inoutHeader); assertNotNull(returnVal); assertNull(returnVal.getResponseType()); assertEquals(val,inoutHeader.value.getRequestType()); in.setRequestType(null); inoutHeader.value.setRequestType(val); returnVal=proxy.testHeader3(in,inoutHeader); assertNotNull(returnVal); assertEquals(val,returnVal.getResponseType()); assertNull(inoutHeader.value.getRequestType()); } } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

IterativeVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testRPCInOutHeader() throws Exception { URL wsdl=getClass().getResource("/wsdl/soapheader_rpc.wsdl"); assertNotNull(wsdl); SOAPRPCHeaderService service=new SOAPRPCHeaderService(wsdl,new QName("http://apache.org/header_test/rpc","SOAPRPCHeaderService")); assertNotNull(service); TestRPCHeader proxy=service.getSoapRPCHeaderPort(); try { HeaderMessage header=new HeaderMessage(); Holder holder=new Holder(header); for (int idx=0; idx < 2; idx++) { holder.value.setHeaderVal("header" + idx); String returnVal=proxy.testInOutHeader("part" + idx,holder); assertNotNull(returnVal); assertEquals("header" + idx,returnVal); assertEquals("part" + idx,holder.value.getHeaderVal()); } } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

IterativeVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testOutHeader() throws Exception { URL wsdl=getClass().getResource("/wsdl/soapheader.wsdl"); assertNotNull(wsdl); SOAPHeaderService service=new SOAPHeaderService(wsdl,serviceName); assertNotNull(service); TestHeader proxy=service.getPort(portName,TestHeader.class); try { TestHeader2 in=new TestHeader2(); String val=new String(TestHeader2Response.class.getSimpleName()); Holder out=new Holder(); Holder outHeader=new Holder(); for (int idx=0; idx < 2; idx++) { val+=idx; in.setRequestType(val); proxy.testHeader2(in,out,outHeader); assertEquals(val,out.value.getResponseType()); assertEquals(val,outHeader.value.getResponseType()); } } catch ( UndeclaredThrowableException ex) { ex.printStackTrace(); throw (Exception)ex.getCause(); } }

IterativeVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testInHeader() throws Exception { URL wsdl=getClass().getResource("/wsdl/soapheader.wsdl"); assertNotNull(wsdl); SOAPHeaderService service=new SOAPHeaderService(wsdl,serviceName); assertNotNull(service); TestHeader proxy=service.getPort(portName,TestHeader.class); try { TestHeader1 val=new TestHeader1(); for (int idx=0; idx < 2; idx++) { TestHeader1Response returnVal=proxy.testHeader1(val,val); assertNotNull(returnVal); assertEquals(TestHeader1.class.getSimpleName(),returnVal.getResponseType()); } } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testHolderOutIsTheFirstMessagePart() throws Exception { URL wsdl=getClass().getResource("/wsdl/soapheader.wsdl"); assertNotNull(wsdl); SOAPHeaderService service=new SOAPHeaderService(wsdl,serviceName); assertNotNull(service); TestHeader proxy=service.getPort(portName,TestHeader.class); Holder simpleAll=new Holder(); SimpleAll sa=new SimpleAll(); sa.setVarAttrString("varAttrString"); sa.setVarInt(100); sa.setVarString("varString"); simpleAll.value=sa; SimpleChoice sc=new SimpleChoice(); sc.setVarString("scVarString"); SimpleStruct ss=proxy.sendReceiveAnyType(simpleAll,sc); assertEquals(simpleAll.value.getVarString(),"scVarString"); assertEquals(ss.getVarInt(),200); assertEquals(ss.getVarAttrString(),"varAttrStringRet"); }

IterativeVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testRPCInHeader() throws Exception { URL wsdl=getClass().getResource("/wsdl/soapheader_rpc.wsdl"); assertNotNull(wsdl); SOAPRPCHeaderService service=new SOAPRPCHeaderService(wsdl,new QName("http://apache.org/header_test/rpc","SOAPRPCHeaderService")); assertNotNull(service); TestRPCHeader proxy=service.getSoapRPCHeaderPort(); try { HeaderMessage header=new HeaderMessage(); header.setHeaderVal("header"); for (int idx=0; idx < 2; idx++) { String returnVal=proxy.testHeader1(header,"part"); assertNotNull(returnVal); assertEquals("part/header",returnVal); } } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

IterativeVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testReturnHeader() throws Exception { URL wsdl=getClass().getResource("/wsdl/soapheader.wsdl"); assertNotNull(wsdl); SOAPHeaderService service=new SOAPHeaderService(wsdl,serviceName); assertNotNull(service); TestHeader proxy=service.getPort(portName,TestHeader.class); try { Holder out=new Holder(); Holder outHeader=new Holder(); TestHeader5 in=new TestHeader5(); String val=new String(TestHeader5.class.getSimpleName()); for (int idx=0; idx < 2; idx++) { val+=idx; in.setRequestType(val); proxy.testHeader5(out,outHeader,in); assertEquals(1000,out.value.getResponseType()); assertEquals(val,outHeader.value.getRequestType()); } } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testHeader7(){ URL wsdl=getClass().getResource("/wsdl/soapheader.wsdl"); assertNotNull(wsdl); SOAPHeaderService service=new SOAPHeaderService(wsdl,serviceName); assertNotNull(service); TestHeader proxy=service.getPort(portName,TestHeader.class); assertEquals("Hello",proxy.testHeader7()); }

Class: org.apache.cxf.jaxws.holder.HolderTest

InternalCallVerifier EqualityVerifier 
@Test public void testClient() throws Exception { EndpointInfo ei=new EndpointInfo(null,"http://schemas.xmlsoap.org/soap/http"); ei.setAddress(address); Destination d=localTransport.getDestination(ei,bus); d.setMessageObserver(new MessageReplayObserver("/org/apache/cxf/jaxws/holder/echoResponse.xml")); JaxWsProxyFactoryBean factory=new JaxWsProxyFactoryBean(); factory.getClientFactoryBean().setServiceClass(HolderService.class); factory.getClientFactoryBean().setBus(getBus()); factory.getClientFactoryBean().setAddress(address); HolderService h=(HolderService)factory.create(); Holder holder=new Holder(); assertEquals("one",h.echo("one","two",holder)); assertEquals("two",holder.value); }

Class: org.apache.cxf.jaxws.provider.ProviderServiceFactoryTest

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSAAJProviderCodeFirst() throws Exception { JaxWsServiceFactoryBean bean=new JaxWsServiceFactoryBean(); bean.setServiceClass(SAAJProvider.class); bean.setBus(getBus()); bean.setInvoker(new JAXWSMethodInvoker(new SAAJProvider())); Service service=bean.create(); assertEquals("SAAJProviderService",service.getName().getLocalPart()); InterfaceInfo intf=service.getServiceInfos().get(0).getInterface(); assertNotNull(intf); assertEquals(1,intf.getOperations().size()); JaxWsServerFactoryBean svrFactory=new JaxWsServerFactoryBean(); svrFactory.setBus(getBus()); svrFactory.setServiceFactory(bean); String address="local://localhost:9000/test"; svrFactory.setAddress(address); ServerImpl server=(ServerImpl)svrFactory.create(); Endpoint endpoint=server.getEndpoint(); Binding binding=endpoint.getBinding(); assertTrue(binding instanceof SoapBinding); SoapBindingInfo sb=(SoapBindingInfo)endpoint.getEndpointInfo().getBinding(); assertEquals("document",sb.getStyle()); assertEquals(false,bean.isWrapped()); assertEquals(1,sb.getOperations().size()); Node res=invoke(address,LocalTransportFactory.TRANSPORT_ID,"/org/apache/cxf/jaxws/sayHi.xml"); addNamespace("j","http://service.jaxws.cxf.apache.org/"); assertValid("/s:Envelope/s:Body/j:sayHi",res); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSOAPBindingFromCode() throws Exception { JaxWsServiceFactoryBean bean=new JaxWsServiceFactoryBean(); bean.setServiceClass(SOAPSourcePayloadProvider.class); bean.setBus(getBus()); bean.setInvoker(new JAXWSMethodInvoker(new SOAPSourcePayloadProvider())); Service service=bean.create(); assertEquals("SOAPSourcePayloadProviderService",service.getName().getLocalPart()); InterfaceInfo intf=service.getServiceInfos().get(0).getInterface(); assertNotNull(intf); assertEquals(1,intf.getOperations().size()); JaxWsServerFactoryBean svrFactory=new JaxWsServerFactoryBean(); svrFactory.setBus(getBus()); svrFactory.setServiceFactory(bean); String address="local://localhost:9000/test"; svrFactory.setAddress(address); ServerImpl server=(ServerImpl)svrFactory.create(); assertEquals(1,service.getServiceInfos().get(0).getEndpoints().size()); Endpoint endpoint=server.getEndpoint(); Binding binding=endpoint.getBinding(); assertTrue(binding instanceof SoapBinding); SoapBindingInfo sb=(SoapBindingInfo)endpoint.getEndpointInfo().getBinding(); assertEquals("document",sb.getStyle()); assertEquals(false,bean.isWrapped()); assertEquals(1,sb.getOperations().size()); Node res=invoke(address,LocalTransportFactory.TRANSPORT_ID,"/org/apache/cxf/jaxws/sayHi.xml"); addNamespace("j","http://service.jaxws.cxf.apache.org/"); assertValid("/s:Envelope/s:Body/j:sayHi",res); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testXMLBindingFromCode() throws Exception { JaxWsServiceFactoryBean bean=new JaxWsServiceFactoryBean(); bean.setServiceClass(DOMSourcePayloadProvider.class); bean.setBus(getBus()); bean.setInvoker(new JAXWSMethodInvoker(new DOMSourcePayloadProvider())); Service service=bean.create(); assertEquals("DOMSourcePayloadProviderService",service.getName().getLocalPart()); InterfaceInfo intf=service.getServiceInfos().get(0).getInterface(); assertNotNull(intf); JaxWsServerFactoryBean svrFactory=new JaxWsServerFactoryBean(); svrFactory.setBus(getBus()); svrFactory.setServiceFactory(bean); String address="http://localhost:9000/test"; svrFactory.setAddress(address); svrFactory.setTransportId(LocalTransportFactory.TRANSPORT_ID); ServerImpl server=(ServerImpl)svrFactory.create(); assertEquals(1,service.getServiceInfos().get(0).getEndpoints().size()); Endpoint endpoint=server.getEndpoint(); Binding binding=endpoint.getBinding(); assertTrue(binding instanceof XMLBinding); Node res=invoke(address,LocalTransportFactory.TRANSPORT_ID,"/org/apache/cxf/jaxws/provider/sayHi.xml"); addNamespace("j","http://service.jaxws.cxf.apache.org/"); assertValid("/j:sayHi",res); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testFromWSDL() throws Exception { URL resource=getClass().getResource("/wsdl/hello_world.wsdl"); assertNotNull(resource); JaxWsImplementorInfo implInfo=new JaxWsImplementorInfo(HWSoapMessageProvider.class); JaxWsServiceFactoryBean bean=new JaxWsServiceFactoryBean(implInfo); bean.setWsdlURL(resource.toString()); Bus bus=getBus(); bean.setBus(bus); bean.setServiceClass(HWSoapMessageProvider.class); Service service=bean.create(); assertTrue(service.getInvoker() instanceof JAXWSMethodInvoker); assertEquals("SOAPService",service.getName().getLocalPart()); assertEquals("http://apache.org/hello_world_soap_http",service.getName().getNamespaceURI()); InterfaceInfo intf=service.getServiceInfos().get(0).getInterface(); assertNotNull(intf); JaxWsServerFactoryBean svrFactory=new JaxWsServerFactoryBean(); svrFactory.setBus(bus); svrFactory.setServiceFactory(bean); svrFactory.setStart(false); ServerImpl server=(ServerImpl)svrFactory.create(); assertTrue(server.getEndpoint().getService().getInvoker() instanceof JAXWSMethodInvoker); Endpoint endpoint=server.getEndpoint(); Binding binding=endpoint.getBinding(); assertTrue(binding instanceof SoapBinding); }

Class: org.apache.cxf.jaxws.spring.SpringBeansTest

UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testEndpointWithUndefinedBus() throws Exception { try { new ClassPathXmlApplicationContext("/org/apache/cxf/jaxws/spring/endpoints3.xml").close(); fail("Should have thrown an exception"); } catch ( BeanCreationException ex) { assertEquals("ep2",ex.getBeanName()); assertTrue(ex.getMessage().contains("cxf1")); } }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCXF3959SpringInject() throws Exception { PostConstructCalledCount.reset(); ClassPathXmlApplicationContext ctx=new ClassPathXmlApplicationContext("/org/apache/cxf/jaxws/spring/cxf3959c.xml"); assertNotNull(ctx); assertEquals(2,PostConstructCalledCount.getCount()); assertEquals(0,PostConstructCalledCount.getInjectedCount()); PostConstructCalledCount pc=ctx.getBean("theBean",PostConstructCalledCount.class); assertNotNull(pc.getContext()); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testServers() throws Exception { ClassPathXmlApplicationContext ctx=new ClassPathXmlApplicationContext(new String[]{"/org/apache/cxf/jaxws/spring/servers.xml"}); JaxWsServerFactoryBean bean; BindingConfiguration bc; SoapBindingConfiguration sbc; bean=(JaxWsServerFactoryBean)ctx.getBean("inlineSoapBindingRPC"); assertNotNull(bean); bc=bean.getBindingConfig(); assertTrue(bc instanceof SoapBindingConfiguration); sbc=(SoapBindingConfiguration)bc; assertEquals("rpc",sbc.getStyle()); bean=(JaxWsServerFactoryBean)ctx.getBean("simple"); assertNotNull(bean); bean=(JaxWsServerFactoryBean)ctx.getBean("inlineWsdlLocation"); assertNotNull(bean); assertEquals(bean.getWsdlLocation(),"wsdl/hello_world_doc_lit.wsdl"); bean=(JaxWsServerFactoryBean)ctx.getBean("inlineSoapBinding"); assertNotNull(bean); bc=bean.getBindingConfig(); assertTrue(bc instanceof SoapBindingConfiguration); sbc=(SoapBindingConfiguration)bc; assertTrue("Not soap version 1.2: " + sbc.getVersion(),sbc.getVersion() instanceof Soap12); bean=(JaxWsServerFactoryBean)ctx.getBean("inlineDataBinding"); boolean found=false; String[] names=ctx.getBeanNamesForType(SpringServerFactoryBean.class); for ( String n : names) { if (n.startsWith(SpringServerFactoryBean.class.getName())) { found=true; } } assertTrue("Could not find server factory with autogenerated id",found); testNamespaceMapping(ctx); }

APIUtilityVerifier InternalCallVerifier IdentityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testClientUsingDifferentBus() throws Exception { ClassPathXmlApplicationContext ctx=new ClassPathXmlApplicationContext(new String[]{"/org/apache/cxf/jaxws/spring/clients.xml"}); Greeter greeter=(Greeter)ctx.getBean("differentBusGreeter"); assertNotNull(greeter); Client client=ClientProxy.getClient(greeter); assertEquals("snarf",client.getBus().getProperty("foo")); Greeter greeter1=(Greeter)ctx.getBean("client1"); assertNotNull(greeter1); Client client1=ClientProxy.getClient(greeter1); assertEquals("barf",client1.getBus().getProperty("foo")); Greeter greeter2=(Greeter)ctx.getBean("wsdlLocation"); assertNotNull(greeter2); Client client2=ClientProxy.getClient(greeter2); assertSame(client1.getBus(),client2.getBus()); ctx.close(); }

EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCXF3959NoImport() throws Exception { PostConstructCalledCount.reset(); ClassPathXmlApplicationContext ctx=new ClassPathXmlApplicationContext("/org/apache/cxf/jaxws/spring/cxf3959b.xml"); assertNotNull(ctx); assertEquals(2,PostConstructCalledCount.getCount()); assertEquals(2,PostConstructCalledCount.getInjectedCount()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier IdentityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testClients() throws Exception { AbstractFactoryBeanDefinitionParser.setFactoriesAreAbstract(false); ClassPathXmlApplicationContext ctx=new ClassPathXmlApplicationContext(new String[]{"/org/apache/cxf/jaxws/spring/clients.xml"}); ClientHolderBean greeters=(ClientHolderBean)ctx.getBean("greeters"); assertEquals(4,greeters.greeterCount()); Object bean=ctx.getBean("client1.proxyFactory"); assertNotNull(bean); Greeter greeter=(Greeter)ctx.getBean("client1"); Greeter greeter2=(Greeter)ctx.getBean("client1"); assertNotNull(greeter); assertNotNull(greeter2); assertSame(greeter,greeter2); Client client=ClientProxy.getClient(greeter); assertNotNull("expected ConduitSelector",client.getConduitSelector()); assertTrue("unexpected ConduitSelector",client.getConduitSelector() instanceof NullConduitSelector); List> inInterceptors=client.getInInterceptors(); boolean saaj=false; boolean logging=false; for ( Interceptor i : inInterceptors) { if (i instanceof SAAJInInterceptor) { saaj=true; } else if (i instanceof LoggingInInterceptor) { logging=true; } } assertTrue(saaj); assertTrue(logging); saaj=false; logging=false; for ( Interceptor i : client.getOutInterceptors()) { if (i instanceof SAAJOutInterceptor) { saaj=true; } else if (i instanceof LoggingOutInterceptor) { logging=true; } } assertTrue(saaj); assertTrue(logging); assertTrue(client.getEndpoint().getService().getDataBinding() instanceof SourceDataBinding); JaxWsProxyFactoryBean factory=(JaxWsProxyFactoryBean)ctx.getBean("wsdlLocation.proxyFactory"); assertNotNull(factory); String wsdlLocation=factory.getWsdlLocation(); assertEquals("We should get the right wsdl location",wsdlLocation,"wsdl/hello_world.wsdl"); factory=(JaxWsProxyFactoryBean)ctx.getBean("inlineSoapBinding.proxyFactory"); assertNotNull(factory); BindingConfiguration bc=factory.getBindingConfig(); assertTrue(bc instanceof SoapBindingConfiguration); SoapBindingConfiguration sbc=(SoapBindingConfiguration)bc; assertTrue(sbc.getVersion() instanceof Soap12); assertTrue("the soap configure should set isMtomEnabled to be true",sbc.isMtomEnabled()); Greeter g1=greeters.getGreet1(); Greeter g2=greeters.getGreet2(); assertNotSame(g1,g2); ctx.close(); }

EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCXF3959NormalImport() throws Exception { PostConstructCalledCount.reset(); ClassPathXmlApplicationContext ctx=new ClassPathXmlApplicationContext("/org/apache/cxf/jaxws/spring/cxf3959a.xml"); assertNotNull(ctx); assertEquals(2,PostConstructCalledCount.getCount()); assertEquals(2,PostConstructCalledCount.getInjectedCount()); }

APIUtilityVerifier BranchVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testEndpoints() throws Exception { ClassPathXmlApplicationContext ctx=new ClassPathXmlApplicationContext(new String[]{"/org/apache/cxf/jaxws/spring/endpoints.xml"}); EndpointImpl ep=getEndpointImplBean("simple",ctx); assertNotNull(ep.getImplementor()); assertNotNull(ep.getServer()); ep=getEndpointImplBean("simpleWithAddress",ctx); if (!(ep.getImplementor() instanceof org.apache.hello_world_soap_http.GreeterImpl)) { fail("can't get the right implementor object"); } assertEquals("http://localhost:8080/simpleWithAddress",ep.getServer().getEndpoint().getEndpointInfo().getAddress()); ep=getEndpointImplBean("inlineImplementor",ctx); if (!(ep.getImplementor() instanceof org.apache.hello_world_soap_http.GreeterImpl)) { fail("can't get the right implementor object"); } org.apache.hello_world_soap_http.GreeterImpl impl=(org.apache.hello_world_soap_http.GreeterImpl)ep.getImplementor(); assertEquals("The property was not injected rightly",impl.getPrefix(),"hello"); assertNotNull(ep.getServer()); ep=getEndpointImplBean("inlineInvoker",ctx); assertTrue(ep.getInvoker() instanceof NullInvoker); assertTrue(ep.getService().getInvoker() instanceof NullInvoker); ep=getEndpointImplBean("simpleWithBindingUri",ctx); assertEquals("get the wrong bindingId",ep.getBindingUri(),"http://cxf.apache.org/bindings/xformat"); assertEquals("get a wrong transportId","http://cxf.apache.org/transports/local",ep.getTransportId()); ep=getEndpointImplBean("simpleWithBinding",ctx); BindingConfiguration bc=ep.getBindingConfig(); assertTrue(bc instanceof SoapBindingConfiguration); SoapBindingConfiguration sbc=(SoapBindingConfiguration)bc; assertTrue(sbc.getVersion() instanceof Soap12); assertTrue("the soap configure should set isMtomEnabled to be true",sbc.isMtomEnabled()); ep=getEndpointImplBean("implementorClass",ctx); assertEquals(Hello.class,ep.getImplementorClass()); assertTrue(ep.getImplementor().getClass() == Object.class); ep=getEndpointImplBean("epWithProps",ctx); assertEquals("bar",ep.getProperties().get("foo")); ep=getEndpointImplBean("classImpl",ctx); assertTrue(ep.getImplementor() instanceof Hello); QName name=ep.getServer().getEndpoint().getService().getName(); assertEquals("http://service.jaxws.cxf.apache.org/service",name.getNamespaceURI()); assertEquals("HelloServiceCustomized",name.getLocalPart()); name=ep.getServer().getEndpoint().getEndpointInfo().getName(); assertEquals("http://service.jaxws.cxf.apache.org/endpoint",name.getNamespaceURI()); assertEquals("HelloEndpointCustomized",name.getLocalPart()); Object bean=ctx.getBean("wsdlLocation"); assertNotNull(bean); ep=getEndpointImplBean("publishedEndpointUrl",ctx); String expectedEndpointUrl="http://cxf.apache.org/Greeter"; assertEquals(expectedEndpointUrl,ep.getPublishedEndpointUrl()); ep=getEndpointImplBean("epWithDataBinding",ctx); DataBinding dataBinding=ep.getDataBinding(); assertTrue(dataBinding instanceof JAXBDataBinding); assertEquals("The namespace map should have an entry",((JAXBDataBinding)dataBinding).getNamespaceMap().size(),1); boolean found=false; String[] names=ctx.getBeanNamesForType(EndpointImpl.class); for ( String n : names) { if (n.startsWith(EndpointImpl.class.getPackage().getName())) { found=true; } } assertTrue("Could not find server factory with autogenerated id",found); ep=getEndpointImplBean("unpublishedEndpoint",ctx); assertFalse("Unpublished endpoint is published",ep.isPublished()); testInterceptors(ctx); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testTwoEndpointsWithTwoBuses() throws Exception { ClassPathXmlApplicationContext ctx=null; Bus cxf1=null; Bus cxf2=null; try { ctx=new ClassPathXmlApplicationContext("/org/apache/cxf/jaxws/spring/endpoints2.xml"); EndpointImpl ep1=(EndpointImpl)ctx.getBean("ep1"); assertNotNull(ep1); cxf1=(Bus)ctx.getBean("cxf1"); assertNotNull(cxf1); assertEquals(cxf1,ep1.getBus()); assertEquals("barf",ep1.getBus().getProperty("foo")); EndpointImpl ep2=(EndpointImpl)ctx.getBean("ep2"); assertNotNull(ep2); cxf2=(Bus)ctx.getBean("cxf2"); assertNotNull(cxf2); assertEquals(cxf2,ep2.getBus()); assertEquals("snarf",ep2.getBus().getProperty("foo")); } finally { if (cxf1 != null) { cxf1.shutdown(true); } if (cxf2 != null) { cxf2.shutdown(true); } if (ctx != null) { ctx.close(); } } }

Class: org.apache.cxf.jaxws.support.ContextPropertiesMappingTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCreateWebServiceContextWithInAttachments(){ Exchange exchange=new ExchangeImpl(); Message inMessage=new MessageImpl(); Collection attachments=new LinkedList(); DataSource source=new ByteDataSource(new byte[0],"text/xml"); DataHandler handler1=new DataHandler(source); attachments.add(new AttachmentImpl("part1",handler1)); DataHandler handler2=new DataHandler(source); attachments.add(new AttachmentImpl("part2",handler2)); inMessage.setAttachments(attachments); inMessage.putAll(message); exchange.setInMessage(inMessage); exchange.setOutMessage(new MessageImpl()); MessageContext ctx=new WrappedMessageContext(exchange.getInMessage(),Scope.APPLICATION); Object inAttachments=ctx.get(MessageContext.INBOUND_MESSAGE_ATTACHMENTS); assertNotNull("inbound attachments object must be initialized",inAttachments); assertTrue("inbound attachments must be in a Map",inAttachments instanceof Map); Map dataHandlers=CastUtils.cast((Map)inAttachments); assertEquals("two inbound attachments expected",2,dataHandlers.size()); assertTrue("part1 attachment is missing",dataHandlers.containsKey("part1")); assertTrue("part1 handler is missing",dataHandlers.get("part1") == handler1); assertTrue("part2 attachment is missing",dataHandlers.containsKey("part2")); assertTrue("part2 handler is missing",dataHandlers.get("part2") == handler2); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCreateWebServiceContext(){ Exchange exchange=new ExchangeImpl(); Message inMessage=new MessageImpl(); Message outMessage=new MessageImpl(); inMessage.putAll(message); exchange.setInMessage(inMessage); exchange.setOutMessage(outMessage); MessageContext ctx=new WrappedMessageContext(exchange.getInMessage(),Scope.APPLICATION); Object requestHeader=ctx.get(MessageContext.HTTP_REQUEST_HEADERS); assertNotNull("the request header should not be null",requestHeader); assertEquals("we should get the request header",requestHeader,HEADER); Object responseHeader=ctx.get(MessageContext.HTTP_RESPONSE_HEADERS); assertNull("the response header should be null",responseHeader); Object outMessageHeader=outMessage.get(Message.PROTOCOL_HEADERS); assertEquals("the outMessage PROTOCOL_HEADERS should be update",responseHeader,outMessageHeader); Object inAttachments=ctx.get(MessageContext.INBOUND_MESSAGE_ATTACHMENTS); assertNotNull("inbound attachments object must be initialized",inAttachments); assertTrue("inbound attachments must be in a Map",inAttachments instanceof Map); assertTrue("no inbound attachments expected",((Map)inAttachments).isEmpty()); }

Class: org.apache.cxf.jaxws.support.JaxWsImplementorInfoTest

EqualityVerifier 
@Test public void testGetWSDLLocation() throws Exception { JaxWsImplementorInfo info=new JaxWsImplementorInfo(CalculatorImpl.class); assertEquals("testutils/calculator.wsdl",info.getWsdlLocation()); }

Class: org.apache.cxf.jaxws.support.JaxWsServiceConfigurationTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDefaultStyle() throws Exception { JaxWsServiceFactoryBean bean=new JaxWsServiceFactoryBean(); bean.setServiceClass(HelloDefault.class); JaxWsServiceConfiguration jwsc=(JaxWsServiceConfiguration)bean.getServiceConfigurations().get(0); jwsc.setServiceFactory(bean); assertNull(jwsc.getStyle()); assertEquals("document",bean.getStyle()); assertNull(jwsc.isWrapped()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetOutPartName() throws Exception { QName opName=new QName("http://cxf.com/","sayHi"); Method sayHiMethod=Hello.class.getMethod("sayHi",new Class[]{}); ServiceInfo si=getMockedServiceModel("/wsdl/default_partname_test.wsdl"); JaxWsServiceConfiguration jwsc=new JaxWsServiceConfiguration(); JaxWsServiceFactoryBean bean=new JaxWsServiceFactoryBean(); bean.setServiceClass(Hello.class); jwsc.setServiceFactory(bean); OperationInfo op=si.getInterface().getOperation(opName); op.setOutput("output",new MessageInfo(op,MessageInfo.Type.OUTPUT,new QName("http://cxf.com/","output"))); QName partName=jwsc.getOutPartName(op,sayHiMethod,-1); assertEquals("get wrong return partName",new QName("http://cxf.com/","return"),partName); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testRPCStyle() throws Exception { JaxWsServiceFactoryBean bean=new JaxWsServiceFactoryBean(); bean.setServiceClass(HelloRPC.class); JaxWsServiceConfiguration jwsc=(JaxWsServiceConfiguration)bean.getServiceConfigurations().get(0); jwsc.setServiceFactory(bean); assertEquals("rpc",jwsc.getStyle()); assertFalse(jwsc.isWrapped()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testDocumentBareStyle() throws Exception { JaxWsServiceFactoryBean bean=new JaxWsServiceFactoryBean(); bean.setServiceClass(HelloBare.class); JaxWsServiceConfiguration jwsc=(JaxWsServiceConfiguration)bean.getServiceConfigurations().get(0); jwsc.setServiceFactory(bean); assertEquals("document",jwsc.getStyle()); assertFalse(jwsc.isWrapped()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testDocumentWrappedStyle() throws Exception { JaxWsServiceFactoryBean bean=new JaxWsServiceFactoryBean(); bean.setServiceClass(HelloWrapped.class); JaxWsServiceConfiguration jwsc=(JaxWsServiceConfiguration)bean.getServiceConfigurations().get(0); jwsc.setServiceFactory(bean); assertEquals("document",jwsc.getStyle()); assertTrue(jwsc.isWrapped()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetInPartName() throws Exception { QName opName=new QName("http://cxf.com/","sayHello"); Method sayHelloMethod=Hello.class.getMethod("sayHello",new Class[]{String.class,String.class}); ServiceInfo si=getMockedServiceModel("/wsdl/default_partname_test.wsdl"); JaxWsServiceFactoryBean bean=new JaxWsServiceFactoryBean(); bean.setServiceClass(Hello.class); JaxWsServiceConfiguration jwsc=(JaxWsServiceConfiguration)bean.getServiceConfigurations().get(0); jwsc.setServiceFactory(bean); OperationInfo op=si.getInterface().getOperation(opName); op.setInput("input",new MessageInfo(op,MessageInfo.Type.INPUT,new QName("http://cxf.com/","input"))); op.setOutput("output",new MessageInfo(op,MessageInfo.Type.OUTPUT,new QName("http://cxf.com/","output"))); QName partName=jwsc.getInPartName(op,sayHelloMethod,0); assertEquals("get wrong in partName for first param",new QName("http://cxf.com/","arg0"),partName); op.getInput().addMessagePart(new QName("arg0")); partName=jwsc.getInPartName(op,sayHelloMethod,1); assertEquals("get wrong in partName for first param",new QName("http://cxf.com/","arg1"),partName); }

Class: org.apache.cxf.jaxws.support.JaxWsServiceFactoryBeanTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testWrappedDocLit() throws Exception { ReflectionServiceFactoryBean bean=new JaxWsServiceFactoryBean(); Bus bus=getBus(); bean.setBus(bus); bean.setServiceClass(org.apache.hello_world_doc_lit.Greeter.class); Service service=bean.create(); ServiceInfo si=service.getServiceInfos().get(0); InterfaceInfo intf=si.getInterface(); assertEquals(4,intf.getOperations().size()); String ns=si.getName().getNamespaceURI(); assertEquals("http://apache.org/hello_world_doc_lit",ns); OperationInfo greetMeOp=intf.getOperation(new QName(ns,"greetMe")); assertNotNull(greetMeOp); assertEquals("greetMe",greetMeOp.getInput().getName().getLocalPart()); assertEquals("http://apache.org/hello_world_doc_lit",greetMeOp.getInput().getName().getNamespaceURI()); List messageParts=greetMeOp.getInput().getMessageParts(); assertEquals(1,messageParts.size()); MessagePartInfo inMessagePart=messageParts.get(0); assertEquals("http://apache.org/hello_world_doc_lit",inMessagePart.getName().getNamespaceURI()); assertEquals("http://apache.org/hello_world_doc_lit/types",inMessagePart.getElementQName().getNamespaceURI()); messageParts=greetMeOp.getOutput().getMessageParts(); assertEquals(1,messageParts.size()); assertEquals("greetMeResponse",greetMeOp.getOutput().getName().getLocalPart()); MessagePartInfo outMessagePart=messageParts.get(0); assertEquals("http://apache.org/hello_world_doc_lit",outMessagePart.getName().getNamespaceURI()); assertEquals("http://apache.org/hello_world_doc_lit/types",outMessagePart.getElementQName().getNamespaceURI()); OperationInfo greetMeOneWayOp=si.getInterface().getOperation(new QName(ns,"greetMeOneWay")); assertEquals(1,greetMeOneWayOp.getInput().getMessageParts().size()); assertNull(greetMeOneWayOp.getOutput()); Collection schemas=si.getSchemas(); assertEquals(1,schemas.size()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testEndpoint() throws Exception { ReflectionServiceFactoryBean bean=new JaxWsServiceFactoryBean(); URL resource=getClass().getResource("/wsdl/hello_world.wsdl"); assertNotNull(resource); bean.setWsdlURL(resource.toString()); Bus bus=getBus(); bean.setBus(bus); bean.setServiceClass(GreeterImpl.class); BeanInvoker invoker=new BeanInvoker(new GreeterImpl()); bean.setInvoker(invoker); Service service=bean.create(); String ns="http://apache.org/hello_world_soap_http"; assertEquals("SOAPService",service.getName().getLocalPart()); assertEquals(ns,service.getName().getNamespaceURI()); InterfaceInfo intf=service.getServiceInfos().get(0).getInterface(); OperationInfo op=intf.getOperation(new QName(ns,"sayHi")); Class wrapper=op.getInput().getMessageParts().get(0).getTypeClass(); assertNotNull(wrapper); wrapper=op.getOutput().getMessageParts().get(0).getTypeClass(); assertNotNull(wrapper); assertEquals(invoker,service.getInvoker()); op=intf.getOperation(new QName(ns,"testDocLitFault")); Collection faults=op.getFaults(); assertEquals(2,faults.size()); FaultInfo f=op.getFault(new QName(ns,"BadRecordLitFault")); assertNotNull(f); Class c=f.getProperty(Class.class.getName(),Class.class); assertNotNull(c); assertEquals(1,f.getMessageParts().size()); MessagePartInfo mpi=f.getMessagePartByIndex(0); assertNotNull(mpi.getTypeClass()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testBareBug() throws Exception { ReflectionServiceFactoryBean bean=new JaxWsServiceFactoryBean(); Bus bus=getBus(); bean.setBus(bus); bean.setServiceClass(org.apache.cxf.test.TestInterfacePort.class); Service service=bean.create(); ServiceInfo si=service.getServiceInfos().get(0); ServiceWSDLBuilder builder=new ServiceWSDLBuilder(bus,si); Definition def=builder.build(); Document wsdl=WSDLFactory.newInstance().newWSDLWriter().getDocument(def); NodeList nodeList=assertValid("/wsdl:definitions/wsdl:types/xsd:schema" + "[@targetNamespace='http://cxf.apache.org/" + "org.apache.cxf.test.TestInterface/xsd']"+ "/xsd:element[@name='getMessage']",wsdl); assertEquals(1,nodeList.getLength()); assertValid("/wsdl:definitions/wsdl:message[@name='setMessage']" + "/wsdl:part[@name = 'parameters'][@element='ns1:setMessage']",wsdl); assertValid("/wsdl:definitions/wsdl:message[@name='echoCharResponse']" + "/wsdl:part[@name = 'y'][@element='ns1:charEl_y']",wsdl); assertValid("/wsdl:definitions/wsdl:message[@name='echoCharResponse']" + "/wsdl:part[@name = 'return'][@element='ns1:charEl_return']",wsdl); assertValid("/wsdl:definitions/wsdl:message[@name='echoCharResponse']" + "/wsdl:part[@name = 'z'][@element='ns1:charEl_z']",wsdl); assertValid("/wsdl:definitions/wsdl:message[@name='echoChar']" + "/wsdl:part[@name = 'x'][@element='ns1:charEl_x']",wsdl); assertValid("/wsdl:definitions/wsdl:message[@name='echoChar']" + "/wsdl:part[@name = 'y'][@element='ns1:charEl_y']",wsdl); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testHolder() throws Exception { ReflectionServiceFactoryBean bean=new JaxWsServiceFactoryBean(); Bus bus=getBus(); bean.setBus(bus); bean.setServiceClass(TestMtomImpl.class); Service service=bean.create(); InterfaceInfo intf=service.getServiceInfos().get(0).getInterface(); OperationInfo op=intf.getOperation(new QName("http://cxf.apache.org/mime","testXop")); assertNotNull(op); Iterator itr=op.getInput().getMessageParts().iterator(); assertTrue(itr.hasNext()); MessagePartInfo part=itr.next(); assertEquals("testXop",part.getElementQName().getLocalPart()); op=op.getUnwrappedOperation(); assertNotNull(op); itr=op.getInput().getMessageParts().iterator(); assertTrue(itr.hasNext()); part=itr.next(); assertEquals("name",part.getName().getLocalPart()); assertEquals(String.class,part.getTypeClass()); }

Class: org.apache.cxf.jaxws.ws.PolicyFeatureTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testServerFactoryWith2007Xml(){ bus=new SpringBusFactory().createBus("/org/apache/cxf/jaxws/ws/server.xml"); JaxWsServerFactoryBean sf=new JaxWsServerFactoryBean(); sf.setServiceBean(new GreeterImpl()); sf.setAddress("http://localhost/test"); sf.setBus(bus); Configurer c=bus.getExtension(Configurer.class); c.configureBean("test",sf); sf.setStart(false); List features=sf.getFeatures(); assertEquals(1,features.size()); Server server=sf.create(); PolicyEngine pe=bus.getExtension(PolicyEngine.class); assertNotNull(pe); List sis=server.getEndpoint().getService().getServiceInfos(); ServiceInfo info=sis.get(0); Policy p2=info.getExtensor(Policy.class); assertNotNull(p2); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testPolicyReference(){ bus=new SpringBusFactory().createBus("/org/apache/cxf/jaxws/ws/server.xml"); JaxWsServerFactoryBean sf=new JaxWsServerFactoryBean(); sf.setServiceBean(new GreeterImpl()); sf.setAddress("http://localhost/test"); sf.setBus(bus); Configurer c=bus.getExtension(Configurer.class); c.configureBean("testExternal",sf); List features=sf.getFeatures(); assertEquals(1,features.size()); sf.setStart(false); Server server=sf.create(); PolicyEngine pe=bus.getExtension(PolicyEngine.class); assertNotNull(pe); List sis=server.getEndpoint().getService().getServiceInfos(); ServiceInfo info=sis.get(0); Policy p=info.getExtensor(Policy.class); assertNotNull(p); assertEquals("External",p.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testServerFactory(){ bus=new CXFBusFactory().createBus(); PolicyEngineImpl pei=new PolicyEngineImpl(); bus.setExtension(pei,PolicyEngine.class); pei.setBus(bus); Policy p=new Policy(); p.setId("test"); JaxWsServerFactoryBean sf=new JaxWsServerFactoryBean(); sf.getFeatures().add(new WSPolicyFeature(p)); sf.setServiceBean(new GreeterImpl()); sf.setAddress("http://localhost/test"); sf.setStart(false); sf.setBus(bus); Server server=sf.create(); List sis=server.getEndpoint().getService().getServiceInfos(); ServiceInfo info=sis.get(0); Policy p2=info.getExtensor(Policy.class); assertEquals(p,p2); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testServerFactoryWith2004Xml(){ bus=new SpringBusFactory().createBus("/org/apache/cxf/jaxws/ws/server.xml"); JaxWsServerFactoryBean sf=new JaxWsServerFactoryBean(); sf.setServiceBean(new GreeterImpl()); sf.setAddress("http://localhost/test"); sf.setBus(bus); Configurer c=bus.getExtension(Configurer.class); c.configureBean("test2004",sf); List features=sf.getFeatures(); assertEquals(1,features.size()); sf.setStart(false); Server server=sf.create(); PolicyEngine pe=bus.getExtension(PolicyEngine.class); assertNotNull(pe); List sis=server.getEndpoint().getService().getServiceInfos(); ServiceInfo info=sis.get(0); Policy p2=info.getExtensor(Policy.class); assertNotNull(p2); }

Class: org.apache.cxf.jca.core.classloader.PlugInClassLoaderTest

InternalCallVerifier EqualityVerifier 
@Test public void testLoadClassWithPlugInClassLoader() throws Exception { Class resultClass=plugInClassLoader.loadClass("org.apache.cxf.jca.dummy.Dummy"); assertEquals("wrong class","org.apache.cxf.jca.dummy.Dummy",resultClass.getName()); assertEquals("class loader must be the plugInClassLoader",plugInClassLoader,resultClass.getClassLoader()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testInheritsClassLoaderProtectionDomain() throws Exception { Class resultClass=plugInClassLoader.loadClass("org.apache.cxf.jca.dummy.Dummy"); ProtectionDomain pd1=plugInClassLoader.getClass().getProtectionDomain(); ProtectionDomain pd2=resultClass.getProtectionDomain(); LOG.info("PluginClassLoader protection domain: " + pd1); LOG.info("resultClass protection domain: " + pd2); assertEquals("protection domain has to be inherited from the PluginClassLoader. ",pd1,pd2); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testLoadClassWithParentClassLoader() throws Exception { Class resultClass=plugInClassLoader.loadClass("org.omg.CORBA.ORB"); assertEquals("wrong class","org.omg.CORBA.ORB",resultClass.getName()); assertTrue("class loader must NOT be the plugInClassLoader",!(plugInClassLoader.equals(resultClass.getClassLoader()))); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testLoadResourceWithPluginClassLoader() throws Exception { Class resultClass=plugInClassLoader.loadClass("org.apache.cxf.jca.dummy.Dummy"); URL url=resultClass.getResource("dummy.txt"); LOG.info("URL: " + url); assertTrue("bad url: " + url,url.toString().startsWith("classloader:")); InputStream configStream=url.openStream(); assertNotNull("stream must not be null. ",configStream); assertTrue("unexpected stream class: " + configStream.getClass(),configStream instanceof java.io.ByteArrayInputStream); byte[] bytes=new byte[10]; configStream.read(bytes,0,bytes.length); String result=IOUtils.newStringFromBytes(bytes); LOG.fine("dummy.txt contents: " + result); assertEquals("unexpected dummy.txt contents.","blah,blah.",result); }

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testLoadNonFilteredButAvailableClassWithPlugInClassLoader() throws Exception { String className="javax.resource.ResourceException"; getClass().getClassLoader().loadClass(className); try { Class claz=plugInClassLoader.loadClass(className); assertEquals("That should be same classloader ",claz.getClassLoader(),getClass().getClassLoader()); } catch ( ClassNotFoundException ex) { fail("Do not Expect ClassNotFoundException"); } }

Class: org.apache.cxf.jca.core.logging.LoggerHelperTest

EqualityVerifier 
@Test public void testSettingLogLevel(){ LoggerHelper.setRootLoggerName(TEST_LOGGER_NAME); LoggerHelper.setLogLevel("INFO"); assertEquals("incorrect log level","INFO",LoggerHelper.getLogLevel()); assertEquals("log level not set on IONA logger","INFO",LogUtils.getLogger(this.getClass(),null,TEST_LOGGER_NAME).getLevel().toString()); }

Class: org.apache.cxf.jca.core.resourceadapter.ManagedConnectionFactoryImplTest

InternalCallVerifier EqualityVerifier 
@Test public void testMatchConnectionSameConnectioRequestInfoBound() throws Exception { Subject subject=null; Set connectionSet=new HashSet(); ConnectionRequestInfo cri=new DummyConnectionRequestInfo(); DummyManagedConnectionImpl con1=new DummyManagedConnectionImpl(mcf,cri,subject); con1.setBound(true); connectionSet.add(con1); ManagedConnection mcon=mcf.matchManagedConnections(connectionSet,subject,cri); assertEquals(con1,mcon); }

InternalCallVerifier EqualityVerifier 
@Test public void testMatchConnectionSameConnectioRequestInfoNotBound() throws Exception { Subject subject=null; Set connectionSet=new HashSet(); ConnectionRequestInfo cri=new DummyConnectionRequestInfo(); DummyManagedConnectionImpl con1=new DummyManagedConnectionImpl(mcf,cri,subject); connectionSet.add(con1); ManagedConnection mcon=mcf.matchManagedConnections(connectionSet,subject,cri); assertEquals(con1,mcon); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testMatchConnectionDifferentConnectioRequestInfoNotBound() throws Exception { ConnectionRequestInfo cri1=new DummyConnectionRequestInfo(); ConnectionRequestInfo cri2=new DummyConnectionRequestInfo(); Subject subject=null; assertTrue("request info object are differnt",cri1 != cri2); Set connectionSet=new HashSet(); DummyManagedConnectionImpl con1=new DummyManagedConnectionImpl(mcf,cri1,subject); connectionSet.add(con1); ManagedConnection mcon=mcf.matchManagedConnections(connectionSet,subject,cri2); assertEquals("incorrect connection returned",con1,mcon); }

Class: org.apache.cxf.jca.core.resourceadapter.ManagedConnectionImplTest

InternalCallVerifier EqualityVerifier 
@Test public void testGetSetConnectionRequestInfo(){ ConnectionRequestInfo ri=new ConnectionRequestInfo(){ } ; mc.setConnectionRequestInfo(ri); assertEquals("Got back what we set",ri,mc.getConnectionRequestInfo()); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetSetSubject(){ Subject s=new Subject(); mc.setSubject(s); assertEquals("Got back what we set",s,mc.getSubject()); }

Class: org.apache.cxf.jca.core.resourceadapter.ResourceAdapterInternalExceptionTest

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testMessageWithIteEx() throws Exception { final String msg="msg"; final String causeMsg="cause"; Exception cause=new RuntimeException(causeMsg); javax.resource.spi.ResourceAdapterInternalException re=new ResourceAdapterInternalException(msg,new java.lang.reflect.InvocationTargetException(cause)); assertTrue(re.toString().indexOf(msg) != -1); assertTrue(re.toString().indexOf("reason") != -1); assertTrue(re.toString().indexOf(causeMsg) != -1); assertEquals(re.getCause(),cause); }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testMessageWithThrowable() throws Exception { final String msg="msg"; final String causeMsg="cause"; Throwable cause=new Throwable(causeMsg); javax.resource.spi.ResourceAdapterInternalException e=new ResourceAdapterInternalException(msg,cause); assertTrue(e.toString().indexOf(msg) != -1); assertTrue(e.toString().indexOf("reason") != -1); assertTrue(e.toString().indexOf(causeMsg) != -1); assertEquals(e.getCause(),cause); }

BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testMessageWithNullTx(){ final String msg="msg1"; msg.intern(); javax.resource.spi.ResourceAdapterInternalException e=new ResourceAdapterInternalException(msg,null); assertTrue(e.toString().indexOf(msg) != -1); assertTrue(e.toString().indexOf("reason") == -1); assertEquals(e.getMessage(),msg); assertNull(e.getCause()); }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testMessageWithEx() throws Exception { final String msg="msg"; final String causeMsg="cause"; Exception cause=new RuntimeException(causeMsg); javax.resource.spi.ResourceAdapterInternalException e=new ResourceAdapterInternalException(msg,cause); assertTrue(e.toString().indexOf(msg) != -1); assertTrue(e.toString().indexOf("reason") != -1); assertTrue(e.toString().indexOf(causeMsg) != -1); assertEquals(e.getCause(),cause); }

EqualityVerifier 
@Test public void testGetLinkedExceptionReturnNotNullIfCauseIsException() throws Exception { java.lang.Throwable cause=new RuntimeException("runtime exception"); ResourceAdapterInternalException re=new ResourceAdapterInternalException("ex",cause); assertEquals("get same exception",cause,re.getLinkedException()); }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testMessage(){ final String msg="msg1"; msg.intern(); Exception e=new ResourceAdapterInternalException(msg); assertTrue(e.toString().indexOf(msg) != -1); assertTrue(e.toString().indexOf("reason") == -1); assertEquals(e.getMessage(),msg); }

EqualityVerifier 
@Test public void testMessageWithIteErroriNotThrow() throws Exception { final String msg="msg"; final String causeMsg="cause"; java.lang.Throwable cause=new java.lang.UnknownError(causeMsg); ResourceAdapterInternalException re=new ResourceAdapterInternalException(msg,new java.lang.reflect.InvocationTargetException(cause)); assertEquals(re.getCause(),cause); }

Class: org.apache.cxf.jca.core.resourceadapter.UriHandlerInitTest

APIUtilityVerifier BranchVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testAppendToProp(){ final Properties properties=System.getProperties(); final String origVal=properties.getProperty(PROP_NAME); if (origVal != null) { try { assertTrue("pkg has been already been appended",origVal.indexOf(PKG_ADD) == -1); new UriHandlerInit(PKG_ADD); String newValue=properties.getProperty(PROP_NAME); assertTrue("pkg has been appended",newValue.indexOf(PKG_ADD) != -1); final int len=newValue.length(); new UriHandlerInit(PKG_ADD); newValue=properties.getProperty(PROP_NAME); assertEquals("prop has not been appended twice, size is unchanged, newVal=" + newValue.length(),newValue.length(),len); } finally { if (origVal != null) { properties.put(PROP_NAME,origVal); } } } }

Class: org.apache.cxf.jca.cxf.AssociatedManagedConnectionFactoryImplTest

InternalCallVerifier EqualityVerifier 
@Test public void testSetResourceAdapter() throws Exception { TestableAssociatedManagedConnectionFactoryImpl mci=new TestableAssociatedManagedConnectionFactoryImpl(); ResourceAdapterImpl rai=new ResourceAdapterImpl(); mci.setResourceAdapter(rai); assertEquals("ResourceAdapter is set",mci.getResourceAdapter(),rai); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testMergeNonDuplicateResourceAdapterProps() throws ResourceException { Properties props=new Properties(); props.setProperty("key1","value1"); ResourceAdapterImpl rai=new ResourceAdapterImpl(props); TestableAssociatedManagedConnectionFactoryImpl mci=new TestableAssociatedManagedConnectionFactoryImpl(); assertEquals("before associate, one props",0,mci.getPluginProps().size()); assertTrue("before associate, key1 not set",!mci.getPluginProps().containsKey("key1")); mci.setResourceAdapter(rai); assertEquals("after associate, two props",1,mci.getPluginProps().size()); assertTrue("after associate, key1 is set",mci.getPluginProps().containsKey("key1")); }

Class: org.apache.cxf.jca.cxf.ConnectionFactoryImplTest

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testInstanceOfReferencable() throws Exception { assertTrue("Instance of Referenceable",cf instanceof Referenceable); assertNull("No ref set",cf.getReference()); Reference ref=EasyMock.createMock(Reference.class); cf.setReference(ref); assertEquals("Got back what was set",ref,cf.getReference()); }

Class: org.apache.cxf.jca.cxf.ManagedConnectionFactoryImplTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testImplementsEqualsAndHashCode() throws Exception { Method equalMethod=mci.getClass().getMethod("equals",new Class[]{Object.class}); Method hashCodeMethod=mci.getClass().getMethod("hashCode",(Class[])null); assertTrue("not Object's equals method",equalMethod != Object.class.getDeclaredMethod("equals",new Class[]{Object.class})); assertTrue("not Object's hashCode method",hashCodeMethod != Object.class.getDeclaredMethod("hashCode",(Class[])null)); assertEquals("equal with its self",mci,mci); assertTrue("not equal with another",!mci.equals(new ManagedConnectionFactoryImpl())); assertTrue("not equal with another thing",!mci.equals(this)); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testCreateManagedConnection() throws Exception { ManagedConnectionFactoryImplTester mcit=new ManagedConnectionFactoryImplTester(); assertTrue("We get a ManagedConnection back",mcit.createManagedConnection(null,null) instanceof ManagedConnection); assertEquals("init was called once",1,mcit.initCalledCount); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testSetEJBServicePropertiesPollInterval() throws Exception { final Integer value=new Integer(10); Properties p=new Properties(); ManagedConnectionFactoryImpl mcf=new ManagedConnectionFactoryImpl(p); mcf.setEJBServicePropertiesPollInterval(value); assertTrue(p.containsValue(value.toString())); assertEquals(value,mcf.getEJBServicePropertiesPollInterval()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testCreateConnectionFactoryCM() throws Exception { ManagedConnectionFactoryImplTester mcit=new ManagedConnectionFactoryImplTester(); ConnectionManager connManager=EasyMock.createMock(ConnectionManager.class); assertTrue("We get a CF back",mcit.createConnectionFactory(connManager) instanceof CXFConnectionFactory); assertEquals("init was called once",1,mcit.initCalledCount); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testSetMonitorEJBServiceProperties() throws Exception { final Boolean value=Boolean.TRUE; Properties p=new Properties(); ManagedConnectionFactoryImpl mcf=new ManagedConnectionFactoryImpl(p); mcf.setMonitorEJBServiceProperties(value); assertTrue(p.containsValue(value.toString())); assertEquals(value,mcf.getMonitorEJBServiceProperties()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testSetEJBServicePropertiesURL() throws Exception { final String name="file://foo.txt"; Properties p=new Properties(); ManagedConnectionFactoryImpl mcf=new ManagedConnectionFactoryImpl(p); mcf.setEJBServicePropertiesURL(name); assertTrue(p.containsValue(name)); assertEquals(name,mcf.getEJBServicePropertiesURL()); }

Class: org.apache.cxf.jca.cxf.ManagedConnectionImplTest

InternalCallVerifier EqualityVerifier 
@Test public void testGetMetaData() throws Exception { ManagedConnectionMetaData data=mci.getMetaData(); assertEquals("Checking the EISProductionVersion","1.1",data.getEISProductVersion()); assertEquals("Checking the EISProductName","WS-based-EIS",data.getEISProductName()); }

Class: org.apache.cxf.jca.cxf.ResourceAdapterImplTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSerializability() throws Exception { final String key="key"; final String value="value"; Properties props=new Properties(); props.setProperty(key,value); ResourceAdapterImpl rai=new ResourceAdapterImpl(props); assertTrue("before serialized, key is set",rai.getPluginProps().containsKey(key)); ByteArrayOutputStream baos=new ByteArrayOutputStream(); ObjectOutputStream oos=new ObjectOutputStream(baos); oos.writeObject(rai); byte[] buf=baos.toByteArray(); oos.close(); baos.close(); ByteArrayInputStream bais=new ByteArrayInputStream(buf); ObjectInputStream ois=new ObjectInputStream(bais); ResourceAdapterImpl rai2=(ResourceAdapterImpl)ois.readObject(); ois.close(); bais.close(); assertNotNull("deserialized is not null",rai2); assertTrue("props not empty",!rai2.getPluginProps().isEmpty()); assertTrue("props contains key",rai2.getPluginProps().containsKey(key)); assertEquals("no change after serialized and reconstitued ",value,rai2.getPluginProps().getProperty(key)); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetCorrectBootstrapContext() throws Exception { ResourceAdapterImpl rai=new ResourceAdapterImpl(); BootstrapContext bc=EasyMock.createMock(BootstrapContext.class); assertNotNull("BootstrapContext not null",bc); rai.start(bc); assertEquals("BootstrapContext set",rai.getBootstrapContext(),bc); }

Class: org.apache.cxf.jca.cxf.handlers.InvocationHandlerFactoryTest

InternalCallVerifier EqualityVerifier 
@Test public void testOrderedHandlerChain() throws Exception { assertEquals(ProxyInvocationHandler.class,handler.getClass()); assertEquals(ObjectMethodInvocationHandler.class,handler.getNext().getClass()); assertEquals(SecurityTestHandler.class,handler.getNext().getNext().getClass()); }

IterativeVerifier BooleanVerifier InternalCallVerifier IdentityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCreateHandlerChain() throws ResourceAdapterInternalException { CXFInvocationHandler first=handler; CXFInvocationHandler last=null; assertNotNull("handler must not be null",handler); int count=0; Set> allHandlerTypes=new HashSet>(); while (handler != null) { assertSame("managed connection must be set",mci,handler.getData().getManagedConnection()); assertSame("bus must be set",mockBus,handler.getData().getBus()); assertSame("subject must be set",testSubject,handler.getData().getSubject()); assertSame("target must be set",target,handler.getData().getTarget()); allHandlerTypes.add(handler.getClass()); last=handler; handler=handler.getNext(); count++; } assertNotNull(last); assertEquals("must create correct number of handlers",count,4); assertTrue("first handler must a ProxyInvocationHandler",first instanceof ProxyInvocationHandler); assertTrue("last handler must be an InvokingInvocationHandler",last instanceof InvokingInvocationHandler); Class[] types={ProxyInvocationHandler.class,ObjectMethodInvocationHandler.class,InvokingInvocationHandler.class,SecurityTestHandler.class}; for (int i=0; i < types.length; i++) { assertTrue("handler chain must contain type: " + types[i],allHandlerTypes.contains(types[i])); } }

Class: org.apache.cxf.jca.cxf.handlers.ObjectMethodInvocationHandlerTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testEqualsThroughProxies(){ Class[] interfaces={TestInterface.class}; CXFInvocationHandlerData data1=new CXFInvocationHandlerDataImpl(); CXFInvocationHandlerData data2=new CXFInvocationHandlerDataImpl(); data1.setTarget(new TestTarget()); data2.setTarget(new TestTarget()); ObjectMethodInvocationHandler handler1=new ObjectMethodInvocationHandler(data1); handler1.setNext(mockHandler); ObjectMethodInvocationHandler handler2=new ObjectMethodInvocationHandler(data2); handler2.setNext(mockHandler); TestInterface proxy1=(TestInterface)Proxy.newProxyInstance(TestInterface.class.getClassLoader(),interfaces,handler1); TestInterface proxy2=(TestInterface)Proxy.newProxyInstance(TestInterface.class.getClassLoader(),interfaces,handler2); assertEquals(proxy1,proxy1); assertTrue(!proxy1.equals(proxy2)); }

Class: org.apache.cxf.jca.outbound.ManagedConnectionImplTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
/** * Verify the connection handle's equals() method */ @Test public void testHandleEqualsMethod() throws Exception { BusFactory.setDefaultBus(null); IMocksControl control=EasyMock.createNiceControl(); ManagedConnectionFactoryImpl mcf=control.createMock(ManagedConnectionFactoryImpl.class); CXFConnectionSpec cxRequestInfo=new CXFConnectionSpec(); cxRequestInfo.setWsdlURL(getClass().getResource("/wsdl/hello_world.wsdl")); cxRequestInfo.setServiceClass(Greeter.class); cxRequestInfo.setEndpointName(new QName("http://apache.org/hello_world_soap_http","SoapPort")); cxRequestInfo.setServiceName(new QName("http://apache.org/hello_world_soap_http","SOAPService")); control.replay(); Subject subject=new Subject(); ManagedConnectionImpl conn=new ManagedConnectionImpl(mcf,cxRequestInfo,subject); Object handle1=conn.getConnection(subject,cxRequestInfo); Object handle2=conn.getConnection(subject,cxRequestInfo); assertEquals(handle1,handle1); assertEquals(handle2,handle2); assertFalse(handle1.equals(handle2)); }

Class: org.apache.cxf.jca.servant.EJBEndpointTest

InternalCallVerifier EqualityVerifier 
@Test public void testGetAddress80Port() throws Exception { int port=endpoint.getAddressPort("http://localhost/services"); assertEquals(80,port); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetAddressPort() throws Exception { int port=endpoint.getAddressPort("http://localhost:8080/services"); assertEquals(8080,port); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetAddressEndPort() throws Exception { int port=endpoint.getAddressPort("http://localhost:9999"); assertEquals(9999,port); }

Class: org.apache.cxf.jca.servant.EJBServantConfigTest

EqualityVerifier 
@Test public void testGetServiceClassName() throws Exception { String value="{http://apache.org/hello_world_soap_http}Greeter@file:"; EJBServantConfig config=new EJBServantConfig("GreeterBean",value); EJBEndpoint endpoint=new EJBEndpoint(config); assertEquals("org.apache.hello_world_soap_http.Greeter",endpoint.getServiceClassName()); }

InternalCallVerifier EqualityVerifier 
@Test public void testFullValue() throws Exception { String value="{http://apache.org/hello_world_soap_http}SOAPService@file:/wsdl/hello_world.wsdl"; QName result=new QName("http://apache.org/hello_world_soap_http","SOAPService"); EJBServantConfig config=new EJBServantConfig(null,value); assertEquals("file:/wsdl/hello_world.wsdl",config.getWsdlURL()); assertEquals(result,config.getServiceName()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testNoWsdl() throws Exception { String value="{http://apache.org/hello_world_soap_http}Greeter"; QName result=new QName("http://apache.org/hello_world_soap_http","Greeter"); EJBServantConfig config=new EJBServantConfig(null,value); assertEquals(result,config.getServiceName()); assertNull(config.getWsdlURL()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testNoWsdlNoNamespace() throws Exception { String value="Greeter"; QName result=new QName("","Greeter"); EJBServantConfig config=new EJBServantConfig(null,value); assertEquals(result,config.getServiceName()); assertNull(config.getWsdlURL()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testWithNullServiceName() throws Exception { String value="@wsdl/hello_world.wsdl"; EJBServantConfig config=new EJBServantConfig(null,value); assertNull(config.getServiceName()); assertEquals("wsdl/hello_world.wsdl",config.getWsdlURL()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testNoWsdlNoLocalPart() throws Exception { String value="{http://apache.org/hello_world_soap_http}"; QName result=new QName("http://apache.org/hello_world_soap_http",""); EJBServantConfig config=new EJBServantConfig(null,value); assertEquals(result,config.getServiceName()); assertNull(config.getWsdlURL()); }

Class: org.apache.cxf.jms.testsuite.testcases.SoapJmsSpecTest

APIUtilityVerifier IterativeVerifier InternalCallVerifier EqualityVerifier 
@Test public void testSpecJMS() throws Exception { QName serviceName=new QName(SERVICE_NS,"JMSGreeterService"); QName portName=new QName(SERVICE_NS,"GreeterPort"); URL wsdl=getWSDLURL(WSDL); JMSGreeterService service=new JMSGreeterService(wsdl,serviceName); JMSGreeterPortType greeter=markForClose(service.getPort(portName,JMSGreeterPortType.class,cff)); for (int idx=0; idx < 5; idx++) { greeter.greetMeOneWay("test String"); String greeting=greeter.greetMe("Milestone-" + idx); Assert.assertEquals("Hello Milestone-" + idx,greeting); String reply=greeter.sayHi(); Assert.assertEquals(new String("Bonjour"),reply); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testWsdlExtensionSpecJMSPortError() throws Exception { QName serviceName=new QName(SERVICE_NS,"JMSGreeterService2"); QName portName=new QName(SERVICE_NS,"GreeterPort2"); URL wsdl=getWSDLURL(WSDL); JMSGreeterService2 service=new JMSGreeterService2(wsdl,serviceName); JMSGreeterPortType greeter=markForClose(service.getPort(portName,JMSGreeterPortType.class,cff)); String reply=greeter.sayHi(); Assert.assertEquals("Bonjour",reply); }

IterativeVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGzip() throws Exception { URL wsdl=getWSDLURL(WSDL); JaxWsProxyFactoryBean factory=new JaxWsProxyFactoryBean(); factory.setBus(bus); factory.setServiceClass(JMSGreeterPortType.class); factory.setWsdlURL(wsdl.toExternalForm()); factory.getFeatures().add(cff); factory.getFeatures().add(new GZIPFeature()); factory.setAddress("jms:queue:test.cxf.jmstransport.queue6"); JMSGreeterPortType greeter=(JMSGreeterPortType)markForClose(factory.create()); for (int idx=0; idx < 5; idx++) { greeter.greetMeOneWay("test String"); String greeting=greeter.greetMe("Milestone-" + idx); Assert.assertEquals("Hello Milestone-" + idx,greeting); String reply=greeter.sayHi(); Assert.assertEquals("Bonjour",reply); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testWsdlExtensionSpecJMS() throws Exception { QName serviceName=new QName(SERVICE_NS,"JMSGreeterService"); QName portName=new QName(SERVICE_NS,"GreeterPort"); URL wsdl=getWSDLURL(WSDL); JMSGreeterService service=new JMSGreeterService(wsdl,serviceName); JMSGreeterPortType greeter=markForClose(service.getPort(portName,JMSGreeterPortType.class,cff)); Map requestContext=((BindingProvider)greeter).getRequestContext(); JMSMessageHeadersType requestHeader=new JMSMessageHeadersType(); requestContext.put(JMSConstants.JMS_CLIENT_REQUEST_HEADERS,requestHeader); String reply=greeter.sayHi(); Assert.assertEquals("Bonjour",reply); requestContext=((BindingProvider)greeter).getRequestContext(); requestHeader=(JMSMessageHeadersType)requestContext.get(JMSConstants.JMS_CLIENT_REQUEST_HEADERS); Assert.assertEquals("1.0",requestHeader.getSOAPJMSBindingVersion()); Assert.assertEquals("\"test\"",requestHeader.getSOAPJMSSOAPAction()); Assert.assertEquals(3000,requestHeader.getTimeToLive()); Assert.assertEquals(DeliveryMode.PERSISTENT,requestHeader.getJMSDeliveryMode()); Assert.assertEquals(7,requestHeader.getJMSPriority()); Map responseContext=((BindingProvider)greeter).getResponseContext(); JMSMessageHeadersType responseHeader=(JMSMessageHeadersType)responseContext.get(JMSConstants.JMS_CLIENT_RESPONSE_HEADERS); Assert.assertEquals("1.0",responseHeader.getSOAPJMSBindingVersion()); Assert.assertEquals(null,responseHeader.getSOAPJMSSOAPAction()); Assert.assertEquals(DeliveryMode.PERSISTENT,responseHeader.getJMSDeliveryMode()); Assert.assertEquals(7,responseHeader.getJMSPriority()); }

Class: org.apache.cxf.js.rhino.AbstractDOMProviderTest

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testNoPortName() throws Exception { EasyMock.expect(scriptMock.get("wsdlLocation",scriptMock)).andReturn("found"); EasyMock.expect(scriptMock.get("serviceName",scriptMock)).andReturn("found"); EasyMock.expect(scriptMock.get("portName",scriptMock)).andReturn(Scriptable.NOT_FOUND); EasyMock.replay(scriptMock); AbstractDOMProvider adp=new DOMMessageProvider(scriptMock,scriptMock,null,false,false); try { adp.publish(); fail("expected exception did not occur"); } catch ( AbstractDOMProvider.JSDOMProviderException ex) { assertEquals("wrong exception message",AbstractDOMProvider.NO_PORT_NAME,ex.getMessage()); } EasyMock.verify(scriptMock); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testNoInvoke() throws Exception { EasyMock.expect(scriptMock.get("wsdlLocation",scriptMock)).andReturn("found"); EasyMock.expect(scriptMock.get("serviceName",scriptMock)).andReturn("found"); EasyMock.expect(scriptMock.get("portName",scriptMock)).andReturn("found"); EasyMock.expect(scriptMock.get("targetNamespace",scriptMock)).andReturn("found"); EasyMock.expect(scriptMock.get("EndpointAddress",scriptMock)).andReturn(epAddr); EasyMock.expect(scriptMock.get("BindingType",scriptMock)).andReturn(Scriptable.NOT_FOUND); EasyMock.expect(scriptMock.get("invoke",scriptMock)).andReturn(Scriptable.NOT_FOUND); EasyMock.replay(scriptMock); AbstractDOMProvider adp=new DOMPayloadProvider(scriptMock,scriptMock,null,false,false); try { adp.publish(); fail("expected exception did not occur"); } catch ( AbstractDOMProvider.JSDOMProviderException ex) { assertEquals("wrong exception message",AbstractDOMProvider.NO_INVOKE,ex.getMessage()); } EasyMock.verify(scriptMock); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testNoTgtNamespace() throws Exception { EasyMock.expect(scriptMock.get("wsdlLocation",scriptMock)).andReturn("found"); EasyMock.expect(scriptMock.get("serviceName",scriptMock)).andReturn("found"); EasyMock.expect(scriptMock.get("portName",scriptMock)).andReturn("found"); EasyMock.expect(scriptMock.get("targetNamespace",scriptMock)).andReturn(Scriptable.NOT_FOUND); EasyMock.replay(scriptMock); AbstractDOMProvider adp=new DOMMessageProvider(scriptMock,scriptMock,null,false,false); try { adp.publish(); fail("expected exception did not occur"); } catch ( AbstractDOMProvider.JSDOMProviderException ex) { assertEquals("wrong exception message",AbstractDOMProvider.NO_TGT_NAMESPACE,ex.getMessage()); } EasyMock.verify(scriptMock); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testNoWsdlLocation() throws Exception { EasyMock.expect(scriptMock.get("wsdlLocation",scriptMock)).andReturn(Scriptable.NOT_FOUND); EasyMock.replay(scriptMock); AbstractDOMProvider adp=new DOMMessageProvider(scriptMock,scriptMock,null,false,false); try { adp.publish(); fail("expected exception did not occur"); } catch ( AbstractDOMProvider.JSDOMProviderException ex) { assertEquals("wrong exception message",AbstractDOMProvider.NO_WSDL_LOCATION,ex.getMessage()); } EasyMock.verify(scriptMock); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testNoSvcName() throws Exception { EasyMock.expect(scriptMock.get("wsdlLocation",scriptMock)).andReturn("found"); EasyMock.expect(scriptMock.get("serviceName",scriptMock)).andReturn(Scriptable.NOT_FOUND); EasyMock.replay(scriptMock); AbstractDOMProvider adp=new DOMPayloadProvider(scriptMock,scriptMock,null,false,false); try { adp.publish(); fail("expected exception did not occur"); } catch ( AbstractDOMProvider.JSDOMProviderException ex) { assertEquals("wrong exception message",AbstractDOMProvider.NO_SERVICE_NAME,ex.getMessage()); } EasyMock.verify(scriptMock); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testNoAddr() throws Exception { EasyMock.expect(scriptMock.get("wsdlLocation",scriptMock)).andReturn("found"); EasyMock.expect(scriptMock.get("serviceName",scriptMock)).andReturn("found"); EasyMock.expect(scriptMock.get("portName",scriptMock)).andReturn("found"); EasyMock.expect(scriptMock.get("targetNamespace",scriptMock)).andReturn("found"); EasyMock.expect(scriptMock.get("EndpointAddress",scriptMock)).andReturn(Scriptable.NOT_FOUND); EasyMock.replay(scriptMock); AbstractDOMProvider adp=new DOMPayloadProvider(scriptMock,scriptMock,null,false,false); try { adp.publish(); fail("expected exception did not occur"); } catch ( AbstractDOMProvider.JSDOMProviderException ex) { assertEquals("wrong exception message",AbstractDOMProvider.NO_EP_ADDR,ex.getMessage()); } EasyMock.verify(scriptMock); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testIllegalInvoke() throws Exception { EasyMock.expect(scriptMock.get("wsdlLocation",scriptMock)).andReturn("found"); EasyMock.expect(scriptMock.get("serviceName",scriptMock)).andReturn("found"); EasyMock.expect(scriptMock.get("portName",scriptMock)).andReturn("found"); EasyMock.expect(scriptMock.get("targetNamespace",scriptMock)).andReturn("found"); EasyMock.expect(scriptMock.get("BindingType",scriptMock)).andReturn(Scriptable.NOT_FOUND); EasyMock.expect(scriptMock.get("invoke",scriptMock)).andReturn("string"); EasyMock.replay(scriptMock); AbstractDOMProvider adp=new DOMMessageProvider(scriptMock,scriptMock,epAddr,true,true); try { adp.publish(); fail("expected exception did not occur"); } catch ( AbstractDOMProvider.JSDOMProviderException ex) { assertEquals("wrong exception message",AbstractDOMProvider.ILLEGAL_INVOKE_TYPE,ex.getMessage()); } EasyMock.verify(scriptMock); }

Class: org.apache.cxf.js.rhino.ProviderFactoryTest

APIUtilityVerifier UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testIllegalServiceModeType() throws Exception { EasyMock.replay(dpMock); final String fname="illegal2.js"; File f=new File(getClass().getResource(fname).toURI().getPath()); try { ph.createAndPublish(f); fail("expected exception did not occur"); } catch ( Exception ex) { assertEquals("wrong exception message",f.getPath() + ProviderFactory.ILLEGAL_SVCMD_TYPE,ex.getMessage()); } EasyMock.verify(dpMock); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testProviderException() throws Exception { dpMock.publish(); EasyMock.expectLastCall().andThrow(new AbstractDOMProvider.JSDOMProviderException(AbstractDOMProvider.NO_EP_ADDR)); EasyMock.replay(dpMock); File f=new File(getClass().getResource("msg.js").toURI().getPath()); try { ph.createAndPublish(f); fail("expected exception did not occur"); } catch ( Exception ex) { assertEquals("wrong exception message",f.getPath() + ": " + AbstractDOMProvider.NO_EP_ADDR,ex.getMessage()); } EasyMock.verify(dpMock); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testNoSuchJSFile() throws Exception { EasyMock.replay(dpMock); final String fname="none.js"; File f=new File(fname); try { ph.createAndPublish(f); fail("expected exception did not occur"); } catch ( Exception ex) { assertEquals("wrong exception message",f.getPath() + ProviderFactory.NO_SUCH_FILE,ex.getMessage()); } EasyMock.verify(dpMock); }

APIUtilityVerifier UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testEmptyJSFile() throws Exception { EasyMock.replay(dpMock); final String fname="empty.js"; File f=new File(getClass().getResource(fname).toURI().getPath()); try { ph.createAndPublish(f); fail("expected exception did not occur"); } catch ( Exception ex) { assertEquals("wrong exception message",f.getPath() + ProviderFactory.NO_PROVIDER,ex.getMessage()); } EasyMock.verify(dpMock); }

APIUtilityVerifier UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testIllegalServiceMode() throws Exception { EasyMock.replay(dpMock); final String fname="illegal1.js"; File f=new File(getClass().getResource(fname).toURI().getPath()); try { ph.createAndPublish(f); fail("expected exception did not occur"); } catch ( Exception ex) { assertEquals("wrong exception message",f.getPath() + ProviderFactory.ILLEGAL_SVCMD_MODE + "bogus",ex.getMessage()); } EasyMock.verify(dpMock); }

Class: org.apache.cxf.js.rhino.ServerAppTest

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testBrokenOptionA(){ EasyMock.replay(phMock); try { ServerApp app=createServerApp(); String[] args={"-a","not-a-url"}; app.start(args); fail("expected exception did not occur"); } catch ( Exception ex) { assertEquals("wrong exception message",ServerApp.WRONG_ADDR_ERR,ex.getMessage()); } EasyMock.verify(phMock); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testMissingOptionB(){ EasyMock.replay(phMock); try { ServerApp app=createServerApp(); String[] args={"-b"}; app.start(args); fail("expected exception did not occur"); } catch ( Exception ex) { assertEquals("wrong exception message",ServerApp.WRONG_BASE_ERR,ex.getMessage()); } EasyMock.verify(phMock); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testMissingOptionA(){ EasyMock.replay(phMock); try { ServerApp app=createServerApp(); String[] args={"-a"}; app.start(args); fail("expected exception did not occur"); } catch ( Exception ex) { assertEquals("wrong exception message",ServerApp.WRONG_ADDR_ERR,ex.getMessage()); } EasyMock.verify(phMock); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testNoArgs(){ EasyMock.replay(phMock); try { ServerApp app=createServerApp(); String[] args={}; app.start(args); fail("expected exception did not occur"); } catch ( Exception ex) { assertEquals("wrong exception message",ServerApp.NO_FILES_ERR,ex.getMessage()); } EasyMock.verify(phMock); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testBrokenOptionB(){ EasyMock.replay(phMock); try { ServerApp app=createServerApp(); String[] args={"-b","not-a-url"}; app.start(args); fail("expected exception did not occur"); } catch ( Exception ex) { assertEquals("wrong exception message",ServerApp.WRONG_BASE_ERR,ex.getMessage()); } EasyMock.verify(phMock); }

Class: org.apache.cxf.management.InstrumentationManagerTest

APIUtilityVerifier IterativeVerifier BranchVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testWorkQueueInstrumentation() throws Exception { SpringBusFactory factory=new SpringBusFactory(); bus=factory.createBus("managed-spring.xml",true); im=bus.getExtension(InstrumentationManager.class); assertTrue("Instrumentation Manager should not be null",im != null); WorkQueueManagerImpl wqm=new WorkQueueManagerImpl(); wqm.setBus(bus); wqm.getAutomaticWorkQueue(); MBeanServer mbs=im.getMBeanServer(); assertNotNull("MBeanServer should be available.",mbs); ObjectName name=new ObjectName(ManagementConstants.DEFAULT_DOMAIN_NAME + ":type=WorkQueues,*"); Set s=mbs.queryNames(name,null); assertEquals(2,s.size()); Iterator it=s.iterator(); while (it.hasNext()) { ObjectName n=it.next(); Long result=(Long)mbs.invoke(n,"getWorkQueueMaxSize",new Object[0],new String[0]); assertEquals(result,Long.valueOf(256)); Integer hwm=(Integer)mbs.invoke(n,"getHighWaterMark",new Object[0],new String[0]); if (n.getCanonicalName().contains("test-wq")) { assertEquals(10,hwm.intValue()); } else { assertEquals(15,hwm.intValue()); } } bus.shutdown(true); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testInstrumentTwoBuses(){ ClassPathXmlApplicationContext context=null; Bus cxf1=null; Bus cxf2=null; try { context=new ClassPathXmlApplicationContext("managed-spring-twobuses.xml"); cxf1=(Bus)context.getBean("cxf1"); InstrumentationManager im1=cxf1.getExtension(InstrumentationManager.class); assertNotNull("Instrumentation Manager of cxf1 should not be null",im1); CounterRepository cr1=cxf1.getExtension(CounterRepository.class); assertNotNull("CounterRepository of cxf1 should not be null",cr1); assertEquals("CounterRepository of cxf1 has the wrong bus",cxf1,cr1.getBus()); cxf2=(Bus)context.getBean("cxf2"); InstrumentationManager im2=cxf2.getExtension(InstrumentationManager.class); assertNotNull("Instrumentation Manager of cxf2 should not be null",im2); CounterRepository cr2=cxf2.getExtension(CounterRepository.class); assertNotNull("CounterRepository of cxf2 should not be null",cr2); assertEquals("CounterRepository of cxf2 has the wrong bus",cxf2,cr2.getBus()); } finally { if (cxf1 != null) { cxf1.shutdown(true); } if (cxf2 != null) { cxf2.shutdown(true); } if (context != null) { context.close(); } } }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testInstrumentBusWithBusProperties(){ ClassPathXmlApplicationContext context=null; Bus cxf1=null; Bus cxf2=null; try { context=new ClassPathXmlApplicationContext("managed-spring-twobuses2.xml"); cxf1=(Bus)context.getBean("cxf1"); InstrumentationManagerImpl im1=(InstrumentationManagerImpl)cxf1.getExtension(InstrumentationManager.class); assertNotNull("Instrumentation Manager of cxf1 should not be null",im1); assertTrue(im1.isEnabled()); assertEquals("service:jmx:rmi:///jndi/rmi://localhost:9914/jmxrmi",im1.getJMXServiceURL()); cxf2=(Bus)context.getBean("cxf2"); InstrumentationManagerImpl im2=(InstrumentationManagerImpl)cxf2.getExtension(InstrumentationManager.class); assertNotNull("Instrumentation Manager of cxf2 should not be null",im2); assertFalse(im2.isEnabled()); assertEquals("service:jmx:rmi:///jndi/rmi://localhost:9913/jmxrmi",im2.getJMXServiceURL()); } finally { if (cxf1 != null) { cxf1.shutdown(true); } if (cxf2 != null) { cxf2.shutdown(true); } if (context != null) { context.close(); } } }

Class: org.apache.cxf.management.counters.CounterRepositoryTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testIncreaseResponseCounter() throws Exception { MessageHandlingTimeRecorder mhtr1=EasyMock.createMock(MessageHandlingTimeRecorder.class); EasyMock.expect(mhtr1.isOneWay()).andReturn(false).anyTimes(); EasyMock.expect(mhtr1.getHandlingTime()).andReturn((long)1000).anyTimes(); EasyMock.expect(mhtr1.getFaultMode()).andReturn(null).anyTimes(); EasyMock.replay(mhtr1); cr.createCounter(operationCounter); cr.increaseCounter(serviceCounter,mhtr1); cr.increaseCounter(operationCounter,mhtr1); ResponseTimeCounter opCounter=(ResponseTimeCounter)cr.getCounter(operationCounter); ResponseTimeCounter sCounter=(ResponseTimeCounter)cr.getCounter(serviceCounter); assertEquals("The operation counter isn't increased",opCounter.getNumInvocations(),1); assertEquals("The operation counter's AvgResponseTime is wrong ",opCounter.getAvgResponseTime(),(long)1000); assertEquals("The operation counter's MaxResponseTime is wrong ",opCounter.getMaxResponseTime(),(long)1000); assertEquals("The operation counter's MinResponseTime is wrong ",opCounter.getMinResponseTime(),(long)1000); assertEquals("The Service counter isn't increased",sCounter.getNumInvocations(),1); MessageHandlingTimeRecorder mhtr2=EasyMock.createMock(MessageHandlingTimeRecorder.class); EasyMock.expect(mhtr2.isOneWay()).andReturn(false).anyTimes(); EasyMock.expect(mhtr2.getHandlingTime()).andReturn((long)2000).anyTimes(); EasyMock.expect(mhtr2.getFaultMode()).andReturn(null).anyTimes(); EasyMock.replay(mhtr2); cr.increaseCounter(serviceCounter,mhtr2); cr.increaseCounter(operationCounter,mhtr2); assertEquals("The operation counter isn't increased",opCounter.getNumInvocations(),2); assertEquals("The operation counter's AvgResponseTime is wrong ",opCounter.getAvgResponseTime(),(long)1500); assertEquals("The operation counter's MaxResponseTime is wrong ",opCounter.getMaxResponseTime(),(long)2000); assertEquals("The operation counter's MinResponseTime is wrong ",opCounter.getMinResponseTime(),(long)1000); assertEquals("The Service counter isn't increased",sCounter.getNumInvocations(),2); opCounter.reset(); assertTrue(opCounter.getNumCheckedApplicationFaults().intValue() == 0); assertTrue(opCounter.getNumInvocations().intValue() == 0); assertTrue(opCounter.getNumLogicalRuntimeFaults().intValue() == 0); assertTrue(opCounter.getNumRuntimeFaults().intValue() == 0); assertTrue(opCounter.getNumUnCheckedApplicationFaults().intValue() == 0); assertTrue(opCounter.getTotalHandlingTime().intValue() == 0); assertTrue(opCounter.getMinResponseTime().intValue() == 0); assertTrue(opCounter.getMaxResponseTime().intValue() == 0); assertTrue(opCounter.getAvgResponseTime().intValue() == 0); verifyBus(); EasyMock.verify(mhtr1); EasyMock.verify(mhtr2); }

InternalCallVerifier EqualityVerifier 
@Test public void testIncreaseOneWayResponseCounter() throws Exception { MessageHandlingTimeRecorder mhtr=EasyMock.createMock(MessageHandlingTimeRecorder.class); EasyMock.expect(mhtr.isOneWay()).andReturn(true).anyTimes(); EasyMock.expect(mhtr.getEndTime()).andReturn((long)100000000).anyTimes(); EasyMock.expect(mhtr.getHandlingTime()).andReturn((long)1000).anyTimes(); EasyMock.expect(mhtr.getFaultMode()).andReturn(null).anyTimes(); EasyMock.replay(mhtr); cr.increaseCounter(serviceCounter,mhtr); cr.increaseCounter(operationCounter,mhtr); ResponseTimeCounter opCounter=(ResponseTimeCounter)cr.getCounter(operationCounter); ResponseTimeCounter sCounter=(ResponseTimeCounter)cr.getCounter(serviceCounter); assertEquals("The operation counter isn't increased",opCounter.getNumInvocations(),1); assertEquals("The Service counter isn't increased",sCounter.getNumInvocations(),1); verifyBus(); EasyMock.verify(mhtr); }

InternalCallVerifier EqualityVerifier 
@Test public void testIncreaseOneWayNoResponseCounter() throws Exception { MessageHandlingTimeRecorder mhtr=EasyMock.createMock(MessageHandlingTimeRecorder.class); EasyMock.expect(mhtr.isOneWay()).andReturn(true).anyTimes(); EasyMock.expect(mhtr.getEndTime()).andReturn((long)0).anyTimes(); EasyMock.expect(mhtr.getFaultMode()).andReturn(null).anyTimes(); EasyMock.replay(mhtr); cr.increaseCounter(serviceCounter,mhtr); cr.increaseCounter(operationCounter,mhtr); ResponseTimeCounter opCounter=(ResponseTimeCounter)cr.getCounter(operationCounter); ResponseTimeCounter sCounter=(ResponseTimeCounter)cr.getCounter(serviceCounter); assertEquals("The operation counter isn't increased",opCounter.getNumInvocations(),1); assertEquals("The Service counter isn't increased",sCounter.getNumInvocations(),1); verifyBus(); EasyMock.verify(mhtr); }

Class: org.apache.cxf.management.jmx.JMXManagedComponentManagerTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testRegisterStandardMBean() throws Exception { ObjectName name=this.registerStandardMBean("yo!"); String result=(String)manager.getMBeanServer().invoke(name,"sayHi",new Object[0],new String[0]); assertEquals("Wazzzuuup yo!",result); }

APIUtilityVerifier UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
/** * Simulate repeated startup and shutdown of the CXF Bus in an environment * where the container and MBeanServer are not shutdown between CXF restarts. */ @Test public void testBusLifecycleListener() throws Exception { this.tearDown(); MBeanServer server=ManagementFactory.getPlatformMBeanServer(); this.manager=new InstrumentationManagerImpl(); this.manager.setDaemon(false); this.manager.setThreaded(false); this.manager.setEnabled(true); this.manager.setJMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:" + PORT + "/jmxrmi"); this.manager.setServer(server); this.manager.init(); ObjectName name=this.registerStandardMBean("yo!"); String result=(String)manager.getMBeanServer().invoke(name,"sayHi",new Object[0],new String[0]); assertEquals("Wazzzuuup yo!",result); try { name=this.registerStandardMBean("yo!"); fail("registered duplicate MBean"); } catch ( InstanceAlreadyExistsException e) { } this.manager.preShutdown(); this.manager.postShutdown(); try { this.manager.getMBeanServer().invoke(name,"sayHi",new Object[0],new String[0]); fail("MBean not unregistered on shutdown."); } catch ( InstanceNotFoundException e) { } this.manager=new InstrumentationManagerImpl(); this.manager.setDaemon(false); this.manager.setThreaded(false); this.manager.setEnabled(true); this.manager.setJMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:" + PORT + "/jmxrmi"); this.manager.setServer(server); this.manager.init(); name=this.registerStandardMBean("yoyo!"); result=(String)manager.getMBeanServer().invoke(name,"sayHi",new Object[0],new String[0]); assertEquals("Wazzzuuup yoyo!",result); }

APIUtilityVerifier UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testRegisterInstrumentation() throws Exception { AnnotationTestInstrumentation im=new AnnotationTestInstrumentation(); ObjectName name=new ObjectName("org.apache.cxf:type=foo,name=bar"); im.setName("John Smith"); manager.register(im,name); Object val=manager.getMBeanServer().getAttribute(name,NAME_ATTRIBUTE); assertEquals("Incorrect result","John Smith",val); try { manager.register(im,name); fail("Registering with existing name should fail."); } catch ( JMException jmex) { } manager.register(im,name,true); val=manager.getMBeanServer().getAttribute(name,NAME_ATTRIBUTE); assertEquals("Incorrect result","John Smith",val); manager.unregister(name); im.setName("Foo Bar"); name=manager.register(im); val=manager.getMBeanServer().getAttribute(name,NAME_ATTRIBUTE); assertEquals("Incorrect result","Foo Bar",val); try { manager.register(im); fail("Registering with existing name should fail."); } catch ( JMException jmex) { } name=manager.register(im,true); val=manager.getMBeanServer().getAttribute(name,NAME_ATTRIBUTE); assertEquals("Incorrect result","Foo Bar",val); manager.unregister(im); }

Class: org.apache.cxf.management.jmx.export.ModelMBeanAssemblerTest

APIUtilityVerifier EqualityVerifier 
@Test public void testOperationInvocation() throws Exception { Object result=getServer().invoke(ton,"add",new Object[]{new Integer(20),new Integer(30)},new String[]{"int","int"}); assertEquals("Incorrect result",new Integer(50),result); }

APIUtilityVerifier IterativeVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetMBeanAttributeInfo() throws Exception { ModelMBeanInfo info=getMBeanInfoFromAssembler(); MBeanAttributeInfo[] inf=info.getAttributes(); assertEquals("Invalid number of Attributes returned",4,inf.length); for (int x=0; x < inf.length; x++) { assertNotNull("MBeanAttributeInfo should not be null",inf[x]); assertNotNull("Description for MBeanAttributeInfo should not be null",inf[x].getDescription()); } }

APIUtilityVerifier IterativeVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetMBeanOperationInfo() throws Exception { ModelMBeanInfo info=getMBeanInfoFromAssembler(); MBeanOperationInfo[] inf=info.getOperations(); assertEquals("Invalid number of Operations returned",10,inf.length); for (int x=0; x < inf.length; x++) { assertNotNull("MBeanOperationInfo should not be null",inf[x]); assertNotNull("Description for MBeanOperationInfo should not be null",inf[x].getDescription()); } }

InternalCallVerifier EqualityVerifier 
@Test public void testSetAttribute() throws Exception { getServer().setAttribute(ton,new Attribute(AGE_ATTRIBUTE,12)); assertEquals("The Age should be ",12,ati.getAge()); getServer().setAttribute(ton,new Attribute(NAME_ATTRIBUTE,"Rob Harrop")); assertEquals("The name should be ","Rob Harrop",ati.getName()); }

EqualityVerifier 
@Test public void testRegisterOperations() throws Exception { ModelMBeanInfo info=getMBeanInfoFromAssembler(); assertEquals("Incorrect number of operations registered",10,info.getOperations().length); }

APIUtilityVerifier EqualityVerifier 
@Test public void testGetAttribute() throws Exception { ati.setName("John Smith"); Object val=getServer().getAttribute(ton,NAME_ATTRIBUTE); assertEquals("Incorrect result","John Smith",val); }

APIUtilityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAttributeHasCorrespondingOperations() throws Exception { ModelMBeanInfo info=getMBeanInfoFromAssembler(); ModelMBeanOperationInfo myOperation=info.getOperation("myOperation"); assertNotNull("get operation should not be null",myOperation); assertEquals("Incorrect myOperation return type","long",myOperation.getReturnType()); ModelMBeanOperationInfo add=info.getOperation("add"); assertNotNull("set operation should not be null",add); assertEquals("Incorrect add method description","Add Two Numbers Together",add.getDescription()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testNotificationMetadata() throws Exception { ModelMBeanInfo info=getMBeanInfoFromAssembler(); MBeanNotificationInfo[] notifications=info.getNotifications(); assertEquals("Incorrect number of notifications",1,notifications.length); assertEquals("Incorrect notification name","My Notification",notifications[0].getName()); String[] notifTypes=notifications[0].getNotifTypes(); assertEquals("Incorrect number of notification types",2,notifTypes.length); assertEquals("Notification type.foo not found","type.foo",notifTypes[0]); assertEquals("Notification type.bar not found","type.bar",notifTypes[1]); }

Class: org.apache.cxf.management.utils.ManagementConsoleTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void paraserCommandTest(){ String[] listArgs=new String[]{"--operation","list"}; mc.parserArguments(listArgs); assertEquals("It is not right operation name","list",mc.operationName); assertEquals("The portName should be cleared","",mc.portName); String[] startArgs=new String[]{"-o","start","--jmx","service:jmx:rmi:///jndi/rmi://localhost:1234/jmxrmi","--service","\"{http://apache.org/hello_world_soap_http}SOAPService\"","--port","\"{http://apache.org/hello_world_soap_http}SoapPort\""}; mc.parserArguments(startArgs); assertEquals("It is not right operation name","start",mc.operationName); assertEquals("It is not right port name","\"{http://apache.org/hello_world_soap_http}SoapPort\"",mc.portName); assertEquals("It is not right service name","\"{http://apache.org/hello_world_soap_http}SOAPService\"",mc.serviceName); assertEquals("It is not a jmx url","service:jmx:rmi:///jndi/rmi://localhost:1234/jmxrmi",mc.jmxServerURL); String[] errorArgs=new String[]{"--op","listAll"}; assertFalse("the arguments are wrong",mc.parserArguments(errorArgs)); }

Class: org.apache.cxf.management.web.logging.ReadOnlyFileStorageTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testReadRecordsWithMultipleFiles() throws Exception { List locations=new ArrayList(); locations.add(getClass().getResource("logs/2011-01-22-karaf.log").toURI().getPath()); locations.add(getClass().getResource("logs/2011-01-23-karaf.log").toURI().getPath()); storage.setLogLocations(locations); List recordsFirstPage1=readPage(1,10,10); readPage(2,10,10); readPage(3,10,10); List recordsPage4=readPage(4,10,10); readPage(4,10,10); readPage(5,10,10); List recordsLastPage1=readPage(6,10,2); LogRecord recordWithExceptionInMessage=recordsPage4.get(4); assertEquals(LogLevel.ERROR,recordWithExceptionInMessage.getLevel()); assertTrue(recordWithExceptionInMessage.getMessage().contains("mvn:org.apache.cxf/cxf-bundle/")); assertTrue(recordWithExceptionInMessage.getMessage().contains("Caused by: org.osgi.framework.BundleException")); List recordsFirstPage2=readPage(1,10,10); compareRecords(recordsFirstPage1,recordsFirstPage2); List recordsLastPage2=readPage(6,10,2); compareRecords(recordsLastPage1,recordsLastPage2); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testReadRecordsWithScanDirectory() throws Exception { String dir=getClass().getResource("logs").toURI().getPath(); storage.setLogLocation(dir); List recordsFirstPage1=readPage(1,10,10); readPage(2,10,10); readPage(3,10,10); List recordsPage4=readPage(4,10,10); readPage(5,10,10); List recordsLastPage1=readPage(6,10,2); LogRecord recordWithExceptionInMessage=recordsPage4.get(4); assertEquals(LogLevel.ERROR,recordWithExceptionInMessage.getLevel()); assertTrue(recordWithExceptionInMessage.getMessage().contains("mvn:org.apache.cxf/cxf-bundle/")); assertTrue(recordWithExceptionInMessage.getMessage().contains("Caused by: org.osgi.framework.BundleException")); List recordsFirstPage2=readPage(1,10,10); compareRecords(recordsFirstPage1,recordsFirstPage2); List recordsLastPage2=readPage(6,10,2); compareRecords(recordsLastPage1,recordsLastPage2); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testReadRecordsWithMultipleFilesAndSearchDates() throws Exception { List locations=new ArrayList(); locations.add(getClass().getResource("logs/2011-01-22-karaf.log").toURI().getPath()); locations.add(getClass().getResource("logs/2011-01-23-karaf.log").toURI().getPath()); storage.setLogLocations(locations); Map props=new HashMap(); props.put(SearchUtils.DATE_FORMAT_PROPERTY,"yyyy-MM-dd'T'HH:mm:ss SSS"); props.put(SearchUtils.TIMEZONE_SUPPORT_PROPERTY,"false"); FiqlParser parser=new FiqlParser(LogRecord.class,props); SearchCondition sc=parser.parse("date==2011-01-22T11:49:17 184"); List recordsFirstPage1=readPage(1,sc,2,1); List recordsFirstPage2=readPage(1,sc,2,1); compareRecords(recordsFirstPage1,recordsFirstPage2); LogRecord record=recordsFirstPage1.get(0); assertEquals("Initializing Timer",record.getMessage()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testReadRecordsWithMultipleFiles2() throws Exception { List locations=new ArrayList(); locations.add(getClass().getResource("logs/2011-01-23-karaf.log").toURI().getPath()); locations.add(getClass().getResource("logs/2011-01-22-karaf.log").toURI().getPath()); storage.setLogLocations(locations); List recordsFirstPage1=readPage(1,10,10); readPage(2,10,10); readPage(3,10,10); readPage(4,10,10); readPage(5,10,10); List recordsLastPage1=readPage(6,10,2); LogRecord recordWithExceptionInMessage=recordsFirstPage1.get(2); assertEquals(LogLevel.ERROR,recordWithExceptionInMessage.getLevel()); assertTrue(recordWithExceptionInMessage.getMessage().contains("mvn:org.apache.cxf/cxf-bundle/")); assertTrue(recordWithExceptionInMessage.getMessage().contains("Caused by: org.osgi.framework.BundleException")); List recordsFirstPage2=readPage(1,10,10); compareRecords(recordsFirstPage1,recordsFirstPage2); List recordsLastPage2=readPage(6,10,2); compareRecords(recordsLastPage1,recordsLastPage2); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testReadRecordsWithMultipleFilesAndSearchDates2() throws Exception { List locations=new ArrayList(); locations.add(getClass().getResource("logs/2011-01-22-karaf.log").toURI().getPath()); locations.add(getClass().getResource("logs/2011-01-23-karaf.log").toURI().getPath()); storage.setLogLocations(locations); Map props=new HashMap(); props.put(SearchUtils.DATE_FORMAT_PROPERTY,"yyyy-MM-dd"); props.put(SearchUtils.TIMEZONE_SUPPORT_PROPERTY,"false"); FiqlParser parser=new FiqlParser(LogRecord.class,props); SearchCondition sc=parser.parse("date=lt=2011-01-23"); List recordsFirstPage1=readPage(1,sc,32,32); readPage(2,sc,32,0); List recordsFirstPage2=readPage(1,sc,32,32); compareRecords(recordsFirstPage1,recordsFirstPage2); LogRecord firstRecord=recordsFirstPage1.get(0); assertEquals("Starting JMX OSGi agent",firstRecord.getMessage()); LogRecord lastRecord=recordsFirstPage1.get(31); assertTrue(lastRecord.getMessage().contains("Pax Web available at")); readPage(2,sc,32,0); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testReadRecordsWithMultiLines() throws Exception { storage.setLogLocation(getClass().getResource("logs/2011-01-23-karaf.log").toURI().getPath()); List recordsFirstPage1=readPage(1,10,10); List recordsLastPage1=readPage(2,10,10); List recordsFirstPage2=readPage(1,10,10); compareRecords(recordsFirstPage1,recordsFirstPage2); List recordsLastPage2=readPage(2,10,10); compareRecords(recordsLastPage1,recordsLastPage2); LogRecord recordWithExceptionInMessage=recordsFirstPage1.get(2); assertEquals(LogLevel.ERROR,recordWithExceptionInMessage.getLevel()); assertTrue(recordWithExceptionInMessage.getMessage().contains("mvn:org.apache.cxf/cxf-bundle/")); assertTrue(recordWithExceptionInMessage.getMessage().contains("Caused by: org.osgi.framework.BundleException")); }

Class: org.apache.cxf.osgi.itests.jaxrs.JaxRsServiceTest

InternalCallVerifier EqualityVerifier 
@Test public void testJaxRsDelete() throws Exception { Response response=wt.path("/books/123").request("application/xml").delete(); Assert.assertEquals(Status.OK.getStatusCode(),response.getStatus()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void postWithValidation() throws Exception { Book book=new Book(); book.setId(-1); book.setName(null); Response response=wt.path("/books-validate/").request("application/xml").post(Entity.xml(book)); Assert.assertEquals(Status.BAD_REQUEST.getStatusCode(),response.getStatus()); book=new Book(); book.setId(3212); book.setName("A Book"); response=wt.path("/books-validate/").request("application/xml").post(Entity.xml(book)); Assert.assertEquals(Status.CREATED.getStatusCode(),response.getStatus()); Assert.assertNotNull(response.getLocation()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testJaxRsPost() throws Exception { Book book=new Book(); book.setId(321); book.setName("New Book"); Response response=wt.path("/books/").request("application/xml").post(Entity.xml(book)); Assert.assertEquals(Status.CREATED.getStatusCode(),response.getStatus()); Assert.assertNotNull(response.getLocation()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testJaxRsPut() throws Exception { Book book=new Book(); book.setId(123); book.setName("Updated Book"); Response response=wt.path("/books/123").request("application/xml").put(Entity.xml(book)); Assert.assertEquals(Status.OK.getStatusCode(),response.getStatus()); }

Class: org.apache.cxf.osgi.itests.soap.HttpServiceTest

InternalCallVerifier EqualityVerifier 
@Test public void testHttpEndpointJetty() throws Exception { Greeter greeter=greeterHttpProxy(HttpTestActivator.PORT); String res=greeter.greetMe("Chris"); Assert.assertEquals("Hi Chris",res); }

InternalCallVerifier EqualityVerifier 
@Test public void testHttpEndpoint() throws Exception { Greeter greeter=greeterHttpProxy("8181"); String res=greeter.greetMe("Chris"); Assert.assertEquals("Hi Chris",res); }

Class: org.apache.cxf.osgi.itests.soap.JmsServiceTest

InternalCallVerifier EqualityVerifier 
@Test public void testJmsEndpoint() throws Exception { Greeter greeter=greeterJms(); String res=greeter.greetMe("Chris"); Assert.assertEquals("Hi Chris",res); }

Class: org.apache.cxf.phase.PhaseInterceptorChainTest

EqualityVerifier 
@Test public void testWrappedInvocation() throws Exception { CountingPhaseInterceptor p1=new CountingPhaseInterceptor("phase1","p1"); WrapperingPhaseInterceptor p2=new WrapperingPhaseInterceptor("phase2","p2"); CountingPhaseInterceptor p3=new CountingPhaseInterceptor("phase3","p3"); message.getInterceptorChain(); EasyMock.expectLastCall().andReturn(chain).anyTimes(); control.replay(); chain.add(p1); chain.add(p2); chain.add(p3); chain.doIntercept(message); assertEquals(1,p1.invoked); assertEquals(1,p2.invoked); assertEquals(1,p3.invoked); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testInsertionInSamePhasePass() throws Exception { AbstractPhaseInterceptor p2=setUpPhaseInterceptor("phase1","p2"); setUpPhaseInterceptorInvocations(p2,false,false); Set after3=new HashSet(); after3.add("p2"); AbstractPhaseInterceptor p3=setUpPhaseInterceptor("phase1","p3",null,after3); setUpPhaseInterceptorInvocations(p3,false,false); InsertingPhaseInterceptor p1=new InsertingPhaseInterceptor(chain,p3,"phase1","p1"); p1.addBefore("p2"); control.replay(); chain.add(p1); chain.add(p2); chain.doIntercept(message); assertEquals(1,p1.invoked); assertEquals(0,p1.faultInvoked); }

InternalCallVerifier EqualityVerifier 
@Test public void testChainInvocationStartFromSpecifiedInterceptor() throws Exception { CountingPhaseInterceptor p1=new CountingPhaseInterceptor("phase1","p1"); CountingPhaseInterceptor p2=new CountingPhaseInterceptor("phase2","p2"); CountingPhaseInterceptor p3=new CountingPhaseInterceptor("phase3","p3"); message.getInterceptorChain(); EasyMock.expectLastCall().andReturn(chain).anyTimes(); control.replay(); chain.add(p1); chain.add(p2); chain.add(p3); chain.doInterceptStartingAfter(message,p2.getId()); assertEquals(0,p1.invoked); assertEquals(0,p2.invoked); assertEquals(1,p3.invoked); }

EqualityVerifier 
@Test public void testInsertionInDifferentPhasePass() throws Exception { AbstractPhaseInterceptor p2=setUpPhaseInterceptor("phase2","p2"); setUpPhaseInterceptorInvocations(p2,false,false); AbstractPhaseInterceptor p3=setUpPhaseInterceptor("phase3","p3"); setUpPhaseInterceptorInvocations(p3,false,false); InsertingPhaseInterceptor p1=new InsertingPhaseInterceptor(chain,p2,"phase1","p1"); control.replay(); chain.add(p3); chain.add(p1); chain.doIntercept(message); assertEquals(1,p1.invoked); assertEquals(0,p1.faultInvoked); }

Class: org.apache.cxf.resource.ClassLoaderResolverTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetAsStream() throws IOException { InputStream in=clr.getAsStream(resourceName); assertNotNull(in); BufferedReader reader=new BufferedReader(new InputStreamReader(in)); String content=reader.readLine(); assertEquals("resource content incorrect",RESOURCE_DATA,content); }

Class: org.apache.cxf.resource.URIResolverTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testJARProtocol() throws Exception { uriResolver=new URIResolver(); byte[] barray=new byte[]{0}; byte[] barray2=new byte[]{1}; String uriStr="jar:" + resourceURL.toString() + "!/wsdl/hello_world.wsdl"; URL jarURL=new URL(uriStr); InputStream is=jarURL.openStream(); assertNotNull(is); if (is != null) { barray=new byte[is.available()]; is.read(barray); is.close(); } uriResolver.resolve("baseUriStr",uriStr,null); InputStream is2=uriResolver.getInputStream(); assertNotNull(is2); if (is2 != null) { barray2=new byte[is2.available()]; is2.read(barray2); is2.close(); } assertEquals(IOUtils.newStringFromBytes(barray),IOUtils.newStringFromBytes(barray2)); }

Class: org.apache.cxf.rs.security.jose.cookbook.JwkJoseCookBookTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testPublicSetAsList() throws Exception { JsonWebKeys jwks=readKeySet("cookbookPublicSet.txt"); List keys=jwks.getKeys(); assertEquals(2,keys.size()); JsonWebKey ecKey=keys.get(0); assertEquals(6,ecKey.asMap().size()); validatePublicEcKey(ecKey); JsonWebKey rsaKey=keys.get(1); assertEquals(5,rsaKey.asMap().size()); validatePublicRsaKey(rsaKey); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testPublicSetAsMap() throws Exception { JsonWebKeys jwks=readKeySet("cookbookPublicSet.txt"); Map> keysMap=jwks.getKeyTypeMap(); assertEquals(2,keysMap.size()); List rsaKeys=keysMap.get(KeyType.RSA); assertEquals(1,rsaKeys.size()); assertEquals(5,rsaKeys.get(0).asMap().size()); validatePublicRsaKey(rsaKeys.get(0)); List ecKeys=keysMap.get(KeyType.EC); assertEquals(1,ecKeys.size()); assertEquals(6,ecKeys.get(0).asMap().size()); validatePublicEcKey(ecKeys.get(0)); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testSecretSetAsList() throws Exception { JsonWebKeys jwks=readKeySet("cookbookSecretSet.txt"); List keys=jwks.getKeys(); assertEquals(2,keys.size()); JsonWebKey signKey=keys.get(0); assertEquals(5,signKey.asMap().size()); validateSecretSignKey(signKey); JsonWebKey encKey=keys.get(1); assertEquals(5,encKey.asMap().size()); validateSecretEncKey(encKey); }

Class: org.apache.cxf.rs.security.jose.cookbook.JwsJoseCookBookTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testMultipleSignatures() throws Exception { try { Cipher.getInstance(AlgorithmUtils.ES_SHA_512_JAVA); } catch ( Throwable t) { Security.addProvider(new BouncyCastleProvider()); } try { JwsJsonProducer jsonProducer=new JwsJsonProducer(PAYLOAD); assertEquals(jsonProducer.getPlainPayload(),PAYLOAD); assertEquals(jsonProducer.getUnsignedEncodedPayload(),ENCODED_PAYLOAD); JwsHeaders firstSignerProtectedHeader=new JwsHeaders(); firstSignerProtectedHeader.setSignatureAlgorithm(SignatureAlgorithm.RS256); JwsHeaders firstSignerUnprotectedHeader=new JwsHeaders(); firstSignerUnprotectedHeader.setKeyId(RSA_KID_VALUE); JsonWebKeys jwks=readKeySet("cookbookPrivateSet.txt"); List keys=jwks.getKeys(); JsonWebKey rsaKey=keys.get(1); jsonProducer.signWith(JwsUtils.getSignatureProvider(rsaKey,SignatureAlgorithm.RS256),firstSignerProtectedHeader,firstSignerUnprotectedHeader); assertEquals(jsonProducer.getSignatureEntries().get(0).toJson(),FIRST_SIGNATURE_ENTRY_MULTIPLE_SIGNATURES); JwsHeaders secondSignerUnprotectedHeader=new JwsHeaders(); secondSignerUnprotectedHeader.setSignatureAlgorithm(SignatureAlgorithm.ES512); secondSignerUnprotectedHeader.setKeyId(ECDSA_KID_VALUE); JsonWebKey ecKey=keys.get(0); jsonProducer.signWith(JwsUtils.getSignatureProvider(ecKey,SignatureAlgorithm.ES512),null,secondSignerUnprotectedHeader); assertEquals(new JsonMapObjectReaderWriter().toJson(jsonProducer.getSignatureEntries().get(1).getUnprotectedHeader()),SECOND_SIGNATURE_UNPROTECTED_HEADER_MULTIPLE_SIGNATURES); assertEquals(jsonProducer.getSignatureEntries().get(1).toJson().length(),SECOND_SIGNATURE_ENTRY_MULTIPLE_SIGNATURES.length()); JwsHeaders thirdSignerProtectedHeader=new JwsHeaders(); thirdSignerProtectedHeader.setSignatureAlgorithm(SignatureAlgorithm.HS256); thirdSignerProtectedHeader.setKeyId(HMAC_KID_VALUE); JsonWebKeys secretJwks=readKeySet("cookbookSecretSet.txt"); List secretKeys=secretJwks.getKeys(); JsonWebKey hmacKey=secretKeys.get(0); jsonProducer.signWith(JwsUtils.getSignatureProvider(hmacKey,SignatureAlgorithm.HS256),thirdSignerProtectedHeader); assertEquals(jsonProducer.getSignatureEntries().get(2).toJson(),THIRD_SIGNATURE_ENTRY_MULTIPLE_SIGNATURES); assertEquals(jsonProducer.getJwsJsonSignedDocument().length(),MULTIPLE_SIGNATURES_JSON_GENERAL_SERIALIZATION.length()); JwsJsonConsumer jsonConsumer=new JwsJsonConsumer(jsonProducer.getJwsJsonSignedDocument()); JsonWebKeys publicJwks=readKeySet("cookbookPublicSet.txt"); List publicKeys=publicJwks.getKeys(); JsonWebKey rsaPublicKey=publicKeys.get(1); JsonWebKey ecPublicKey=publicKeys.get(0); assertTrue(jsonConsumer.verifySignatureWith(rsaPublicKey,SignatureAlgorithm.RS256)); assertTrue(jsonConsumer.verifySignatureWith(ecPublicKey,SignatureAlgorithm.ES512)); assertTrue(jsonConsumer.verifySignatureWith(hmacKey,SignatureAlgorithm.HS256)); } finally { Security.removeProvider(BouncyCastleProvider.PROVIDER_NAME); } }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testRSAv15Signature() throws Exception { JwsCompactProducer compactProducer=new JwsCompactProducer(PAYLOAD); compactProducer.getJwsHeaders().setSignatureAlgorithm(SignatureAlgorithm.RS256); compactProducer.getJwsHeaders().setKeyId(RSA_KID_VALUE); JsonMapObjectReaderWriter reader=new JsonMapObjectReaderWriter(); assertEquals(reader.toJson(compactProducer.getJwsHeaders().asMap()),RSA_V1_5_SIGNATURE_PROTECTED_HEADER_JSON); assertEquals(compactProducer.getUnsignedEncodedJws(),RSA_V1_5_SIGNATURE_PROTECTED_HEADER + "." + ENCODED_PAYLOAD); JsonWebKeys jwks=readKeySet("cookbookPrivateSet.txt"); List keys=jwks.getKeys(); JsonWebKey rsaKey=keys.get(1); compactProducer.signWith(rsaKey); assertEquals(compactProducer.getSignedEncodedJws(),RSA_V1_5_SIGNATURE_PROTECTED_HEADER + "." + ENCODED_PAYLOAD+ "."+ RSA_V1_5_SIGNATURE_VALUE); JwsCompactConsumer compactConsumer=new JwsCompactConsumer(compactProducer.getSignedEncodedJws()); JsonWebKeys publicJwks=readKeySet("cookbookPublicSet.txt"); List publicKeys=publicJwks.getKeys(); JsonWebKey rsaPublicKey=publicKeys.get(1); assertTrue(compactConsumer.verifySignatureWith(rsaPublicKey,SignatureAlgorithm.RS256)); JwsJsonProducer jsonProducer=new JwsJsonProducer(PAYLOAD); assertEquals(jsonProducer.getPlainPayload(),PAYLOAD); assertEquals(jsonProducer.getUnsignedEncodedPayload(),ENCODED_PAYLOAD); JwsHeaders protectedHeader=new JwsHeaders(); protectedHeader.setSignatureAlgorithm(SignatureAlgorithm.RS256); protectedHeader.setKeyId(RSA_KID_VALUE); jsonProducer.signWith(JwsUtils.getSignatureProvider(rsaKey,SignatureAlgorithm.RS256),protectedHeader); assertEquals(jsonProducer.getJwsJsonSignedDocument(),RSA_V1_5_JSON_GENERAL_SERIALIZATION); JwsJsonConsumer jsonConsumer=new JwsJsonConsumer(jsonProducer.getJwsJsonSignedDocument()); assertTrue(jsonConsumer.verifySignatureWith(rsaPublicKey,SignatureAlgorithm.RS256)); jsonProducer=new JwsJsonProducer(PAYLOAD,true); jsonProducer.signWith(JwsUtils.getSignatureProvider(rsaKey,SignatureAlgorithm.RS256),protectedHeader); assertEquals(jsonProducer.getJwsJsonSignedDocument(),RSA_V1_5_JSON_FLATTENED_SERIALIZATION); jsonConsumer=new JwsJsonConsumer(jsonProducer.getJwsJsonSignedDocument()); assertTrue(jsonConsumer.verifySignatureWith(rsaPublicKey,SignatureAlgorithm.RS256)); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testHMACSignature() throws Exception { JwsCompactProducer compactProducer=new JwsCompactProducer(PAYLOAD); compactProducer.getJwsHeaders().setSignatureAlgorithm(SignatureAlgorithm.HS256); compactProducer.getJwsHeaders().setKeyId(HMAC_KID_VALUE); JsonMapObjectReaderWriter reader=new JsonMapObjectReaderWriter(); assertEquals(reader.toJson(compactProducer.getJwsHeaders().asMap()),HMAC_SIGNATURE_PROTECTED_HEADER_JSON); assertEquals(compactProducer.getUnsignedEncodedJws(),HMAC_SIGNATURE_PROTECTED_HEADER + "." + ENCODED_PAYLOAD); JsonWebKeys jwks=readKeySet("cookbookSecretSet.txt"); List keys=jwks.getKeys(); JsonWebKey key=keys.get(0); compactProducer.signWith(key); assertEquals(compactProducer.getSignedEncodedJws(),HMAC_SIGNATURE_PROTECTED_HEADER + "." + ENCODED_PAYLOAD+ "."+ HMAC_SIGNATURE_VALUE); JwsCompactConsumer compactConsumer=new JwsCompactConsumer(compactProducer.getSignedEncodedJws()); assertTrue(compactConsumer.verifySignatureWith(key,SignatureAlgorithm.HS256)); JwsJsonProducer jsonProducer=new JwsJsonProducer(PAYLOAD); assertEquals(jsonProducer.getPlainPayload(),PAYLOAD); assertEquals(jsonProducer.getUnsignedEncodedPayload(),ENCODED_PAYLOAD); JwsHeaders protectedHeader=new JwsHeaders(); protectedHeader.setSignatureAlgorithm(SignatureAlgorithm.HS256); protectedHeader.setKeyId(HMAC_KID_VALUE); jsonProducer.signWith(JwsUtils.getSignatureProvider(key,SignatureAlgorithm.HS256),protectedHeader); assertEquals(jsonProducer.getJwsJsonSignedDocument(),HMAC_JSON_GENERAL_SERIALIZATION); JwsJsonConsumer jsonConsumer=new JwsJsonConsumer(jsonProducer.getJwsJsonSignedDocument()); assertTrue(jsonConsumer.verifySignatureWith(key,SignatureAlgorithm.HS256)); jsonProducer=new JwsJsonProducer(PAYLOAD,true); jsonProducer.signWith(JwsUtils.getSignatureProvider(key,SignatureAlgorithm.HS256),protectedHeader); assertEquals(jsonProducer.getJwsJsonSignedDocument(),HMAC_JSON_FLATTENED_SERIALIZATION); jsonConsumer=new JwsJsonConsumer(jsonProducer.getJwsJsonSignedDocument()); assertTrue(jsonConsumer.verifySignatureWith(key,SignatureAlgorithm.HS256)); }

EqualityVerifier 
@Test public void testEncodedPayload() throws Exception { assertEquals(Base64UrlUtility.encode(PAYLOAD),ENCODED_PAYLOAD); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testRSAPSSSignature() throws Exception { try { Cipher.getInstance(AlgorithmUtils.PS_SHA_384_JAVA); } catch ( Throwable t) { Security.addProvider(new BouncyCastleProvider()); } JwsCompactProducer compactProducer=new JwsCompactProducer(PAYLOAD); compactProducer.getJwsHeaders().setSignatureAlgorithm(SignatureAlgorithm.PS384); compactProducer.getJwsHeaders().setKeyId(RSA_KID_VALUE); JsonMapObjectReaderWriter reader=new JsonMapObjectReaderWriter(); assertEquals(reader.toJson(compactProducer.getJwsHeaders().asMap()),RSA_PSS_SIGNATURE_PROTECTED_HEADER_JSON); assertEquals(compactProducer.getUnsignedEncodedJws(),RSA_PSS_SIGNATURE_PROTECTED_HEADER + "." + ENCODED_PAYLOAD); JsonWebKeys jwks=readKeySet("cookbookPrivateSet.txt"); List keys=jwks.getKeys(); JsonWebKey rsaKey=keys.get(1); compactProducer.signWith(rsaKey); assertEquals(compactProducer.getSignedEncodedJws().length(),(RSA_PSS_SIGNATURE_PROTECTED_HEADER + "." + ENCODED_PAYLOAD+ "."+ RSA_PSS_SIGNATURE_VALUE).length()); JwsCompactConsumer compactConsumer=new JwsCompactConsumer(compactProducer.getSignedEncodedJws()); JsonWebKeys publicJwks=readKeySet("cookbookPublicSet.txt"); List publicKeys=publicJwks.getKeys(); JsonWebKey rsaPublicKey=publicKeys.get(1); assertTrue(compactConsumer.verifySignatureWith(rsaPublicKey,SignatureAlgorithm.PS384)); JwsJsonProducer jsonProducer=new JwsJsonProducer(PAYLOAD); assertEquals(jsonProducer.getPlainPayload(),PAYLOAD); assertEquals(jsonProducer.getUnsignedEncodedPayload(),ENCODED_PAYLOAD); JwsHeaders protectedHeader=new JwsHeaders(); protectedHeader.setSignatureAlgorithm(SignatureAlgorithm.PS384); protectedHeader.setKeyId(RSA_KID_VALUE); jsonProducer.signWith(JwsUtils.getSignatureProvider(rsaKey,SignatureAlgorithm.PS384),protectedHeader); assertEquals(jsonProducer.getJwsJsonSignedDocument().length(),RSA_PSS_JSON_GENERAL_SERIALIZATION.length()); JwsJsonConsumer jsonConsumer=new JwsJsonConsumer(jsonProducer.getJwsJsonSignedDocument()); assertTrue(jsonConsumer.verifySignatureWith(rsaPublicKey,SignatureAlgorithm.PS384)); jsonProducer=new JwsJsonProducer(PAYLOAD,true); jsonProducer.signWith(JwsUtils.getSignatureProvider(rsaKey,SignatureAlgorithm.PS384),protectedHeader); assertEquals(jsonProducer.getJwsJsonSignedDocument().length(),RSA_PSS_JSON_FLATTENED_SERIALIZATION.length()); jsonConsumer=new JwsJsonConsumer(jsonProducer.getJwsJsonSignedDocument()); assertTrue(jsonConsumer.verifySignatureWith(rsaPublicKey,SignatureAlgorithm.PS384)); Security.removeProvider(BouncyCastleProvider.PROVIDER_NAME); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testDetachedHMACSignature() throws Exception { JwsCompactProducer compactProducer=new JwsCompactProducer(PAYLOAD,true); compactProducer.getJwsHeaders().setSignatureAlgorithm(SignatureAlgorithm.HS256); compactProducer.getJwsHeaders().setKeyId(HMAC_KID_VALUE); JsonMapObjectReaderWriter reader=new JsonMapObjectReaderWriter(); assertEquals(reader.toJson(compactProducer.getJwsHeaders().asMap()),HMAC_SIGNATURE_PROTECTED_HEADER_JSON); assertEquals(compactProducer.getUnsignedEncodedJws(),HMAC_SIGNATURE_PROTECTED_HEADER + "."); JsonWebKeys jwks=readKeySet("cookbookSecretSet.txt"); List keys=jwks.getKeys(); JsonWebKey key=keys.get(0); compactProducer.signWith(key); assertEquals(compactProducer.getSignedEncodedJws(),DETACHED_HMAC_JWS); JwsCompactConsumer compactConsumer=new JwsCompactConsumer(compactProducer.getSignedEncodedJws(),ENCODED_PAYLOAD); assertTrue(compactConsumer.verifySignatureWith(key,SignatureAlgorithm.HS256)); JwsJsonProducer jsonProducer=new JwsJsonProducer(PAYLOAD); assertEquals(jsonProducer.getPlainPayload(),PAYLOAD); assertEquals(jsonProducer.getUnsignedEncodedPayload(),ENCODED_PAYLOAD); JwsHeaders protectedHeader=new JwsHeaders(); protectedHeader.setSignatureAlgorithm(SignatureAlgorithm.HS256); protectedHeader.setKeyId(HMAC_KID_VALUE); jsonProducer.signWith(JwsUtils.getSignatureProvider(key,SignatureAlgorithm.HS256),protectedHeader); assertEquals(jsonProducer.getJwsJsonSignedDocument(true),HMAC_DETACHED_JSON_GENERAL_SERIALIZATION); JwsJsonConsumer jsonConsumer=new JwsJsonConsumer(jsonProducer.getJwsJsonSignedDocument(true),ENCODED_PAYLOAD); assertTrue(jsonConsumer.verifySignatureWith(key,SignatureAlgorithm.HS256)); jsonProducer=new JwsJsonProducer(PAYLOAD,true); jsonProducer.signWith(JwsUtils.getSignatureProvider(key,SignatureAlgorithm.HS256),protectedHeader); assertEquals(jsonProducer.getJwsJsonSignedDocument(true),HMAC_DETACHED_JSON_FLATTENED_SERIALIZATION); jsonConsumer=new JwsJsonConsumer(jsonProducer.getJwsJsonSignedDocument(true),ENCODED_PAYLOAD); assertTrue(jsonConsumer.verifySignatureWith(key,SignatureAlgorithm.HS256)); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testProtectingSpecificHeaderFieldsSignature() throws Exception { JwsJsonProducer jsonProducer=new JwsJsonProducer(PAYLOAD); assertEquals(jsonProducer.getPlainPayload(),PAYLOAD); assertEquals(jsonProducer.getUnsignedEncodedPayload(),ENCODED_PAYLOAD); JwsHeaders protectedHeader=new JwsHeaders(); protectedHeader.setSignatureAlgorithm(SignatureAlgorithm.HS256); JwsHeaders unprotectedHeader=new JwsHeaders(); unprotectedHeader.setKeyId(HMAC_KID_VALUE); JsonWebKeys jwks=readKeySet("cookbookSecretSet.txt"); List keys=jwks.getKeys(); JsonWebKey key=keys.get(0); jsonProducer.signWith(JwsUtils.getSignatureProvider(key,SignatureAlgorithm.HS256),protectedHeader,unprotectedHeader); assertEquals(jsonProducer.getJwsJsonSignedDocument(),PROTECTING_SPECIFIC_HEADER_FIELDS_JSON_GENERAL_SERIALIZATION); JwsJsonConsumer jsonConsumer=new JwsJsonConsumer(jsonProducer.getJwsJsonSignedDocument()); assertTrue(jsonConsumer.verifySignatureWith(key,SignatureAlgorithm.HS256)); jsonProducer=new JwsJsonProducer(PAYLOAD,true); jsonProducer.signWith(JwsUtils.getSignatureProvider(key,SignatureAlgorithm.HS256),protectedHeader,unprotectedHeader); assertEquals(jsonProducer.getJwsJsonSignedDocument(),PROTECTING_SPECIFIC_HEADER_FIELDS_JSON_FLATTENED_SERIALIZATION); jsonConsumer=new JwsJsonConsumer(jsonProducer.getJwsJsonSignedDocument()); assertTrue(jsonConsumer.verifySignatureWith(key,SignatureAlgorithm.HS256)); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testECDSASignature() throws Exception { try { Cipher.getInstance(AlgorithmUtils.ES_SHA_512_JAVA); } catch ( Throwable t) { Security.addProvider(new BouncyCastleProvider()); } try { JwsCompactProducer compactProducer=new JwsCompactProducer(PAYLOAD); compactProducer.getJwsHeaders().setSignatureAlgorithm(SignatureAlgorithm.ES512); compactProducer.getJwsHeaders().setKeyId(ECDSA_KID_VALUE); JsonMapObjectReaderWriter reader=new JsonMapObjectReaderWriter(); assertEquals(reader.toJson(compactProducer.getJwsHeaders().asMap()),ECDSA_SIGNATURE_PROTECTED_HEADER_JSON); assertEquals(compactProducer.getUnsignedEncodedJws(),ECSDA_SIGNATURE_PROTECTED_HEADER + "." + ENCODED_PAYLOAD); JsonWebKeys jwks=readKeySet("cookbookPrivateSet.txt"); List keys=jwks.getKeys(); JsonWebKey ecKey=keys.get(0); compactProducer.signWith(new EcDsaJwsSignatureProvider(JwkUtils.toECPrivateKey(ecKey),SignatureAlgorithm.ES512)); assertEquals(compactProducer.getUnsignedEncodedJws(),ECSDA_SIGNATURE_PROTECTED_HEADER + "." + ENCODED_PAYLOAD); assertEquals(132,Base64UrlUtility.decode(compactProducer.getEncodedSignature()).length); JwsCompactConsumer compactConsumer=new JwsCompactConsumer(compactProducer.getSignedEncodedJws()); JsonWebKeys publicJwks=readKeySet("cookbookPublicSet.txt"); List publicKeys=publicJwks.getKeys(); JsonWebKey ecPublicKey=publicKeys.get(0); assertTrue(compactConsumer.verifySignatureWith(ecPublicKey,SignatureAlgorithm.ES512)); } finally { Security.removeProvider(BouncyCastleProvider.PROVIDER_NAME); } }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testProtectingContentOnlySignature() throws Exception { JwsJsonProducer jsonProducer=new JwsJsonProducer(PAYLOAD); assertEquals(jsonProducer.getPlainPayload(),PAYLOAD); assertEquals(jsonProducer.getUnsignedEncodedPayload(),ENCODED_PAYLOAD); JwsHeaders unprotectedHeader=new JwsHeaders(); unprotectedHeader.setSignatureAlgorithm(SignatureAlgorithm.HS256); unprotectedHeader.setKeyId(HMAC_KID_VALUE); JsonWebKeys jwks=readKeySet("cookbookSecretSet.txt"); List keys=jwks.getKeys(); JsonWebKey key=keys.get(0); jsonProducer.signWith(JwsUtils.getSignatureProvider(key,SignatureAlgorithm.HS256),null,unprotectedHeader); assertEquals(jsonProducer.getJwsJsonSignedDocument(),PROTECTING_CONTENT_ONLY_JSON_GENERAL_SERIALIZATION); JwsJsonConsumer jsonConsumer=new JwsJsonConsumer(jsonProducer.getJwsJsonSignedDocument()); assertTrue(jsonConsumer.verifySignatureWith(key,SignatureAlgorithm.HS256)); jsonProducer=new JwsJsonProducer(PAYLOAD,true); jsonProducer.signWith(JwsUtils.getSignatureProvider(key,SignatureAlgorithm.HS256),null,unprotectedHeader); assertEquals(jsonProducer.getJwsJsonSignedDocument(),PROTECTING_CONTENT_ONLY_JSON_FLATTENED_SERIALIZATION); jsonConsumer=new JwsJsonConsumer(jsonProducer.getJwsJsonSignedDocument()); assertTrue(jsonConsumer.verifySignatureWith(key,SignatureAlgorithm.HS256)); }

Class: org.apache.cxf.rs.security.jose.jwe.JweCompactReaderWriterTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testEncryptDecryptAesWrapA128CBCHS256() throws Exception { final String specPlainText="Live long and prosper."; byte[] cekEncryptionKey=Base64UrlUtility.decode(KEY_ENCRYPTION_KEY_A3); AesWrapKeyEncryptionAlgorithm keyEncryption=new AesWrapKeyEncryptionAlgorithm(cekEncryptionKey,KeyAlgorithm.A128KW); JweEncryptionProvider encryption=new AesCbcHmacJweEncryption(ContentAlgorithm.A128CBC_HS256,CONTENT_ENCRYPTION_KEY_A3,INIT_VECTOR_A3,keyEncryption); String jweContent=encryption.encrypt(specPlainText.getBytes(StandardCharsets.UTF_8),null); assertEquals(JWE_OUTPUT_A3,jweContent); AesWrapKeyDecryptionAlgorithm keyDecryption=new AesWrapKeyDecryptionAlgorithm(cekEncryptionKey); JweDecryptionProvider decryption=new AesCbcHmacJweDecryption(keyDecryption); String decryptedText=decryption.decrypt(jweContent).getContentText(); assertEquals(specPlainText,decryptedText); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testEncryptDecryptRSA15WrapA128CBCHS256() throws Exception { final String specPlainText="Live long and prosper."; RSAPublicKey publicKey=CryptoUtils.getRSAPublicKey(RSA_MODULUS_ENCODED_A1,RSA_PUBLIC_EXPONENT_ENCODED_A1); KeyEncryptionProvider keyEncryption=new RSAKeyEncryptionAlgorithm(publicKey,KeyAlgorithm.RSA1_5); JweEncryptionProvider encryption=new AesCbcHmacJweEncryption(ContentAlgorithm.A128CBC_HS256,CONTENT_ENCRYPTION_KEY_A3,INIT_VECTOR_A3,keyEncryption); String jweContent=encryption.encrypt(specPlainText.getBytes(StandardCharsets.UTF_8),null); RSAPrivateKey privateKey=CryptoUtils.getRSAPrivateKey(RSA_MODULUS_ENCODED_A1,RSA_PRIVATE_EXPONENT_ENCODED_A1); KeyDecryptionProvider keyDecryption=new RSAKeyDecryptionAlgorithm(privateKey,KeyAlgorithm.RSA1_5); JweDecryptionProvider decryption=new AesCbcHmacJweDecryption(keyDecryption); String decryptedText=decryption.decrypt(jweContent).getContentText(); assertEquals(specPlainText,decryptedText); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testEncryptDecryptAesGcmWrapA128CBCHS256() throws Exception { if ("IBM Corporation".equals(System.getProperty("java.vendor"))) { return; } final String specPlainText="Live long and prosper."; byte[] cekEncryptionKey=Base64UrlUtility.decode(KEY_ENCRYPTION_KEY_A3); AesGcmWrapKeyEncryptionAlgorithm keyEncryption=new AesGcmWrapKeyEncryptionAlgorithm(cekEncryptionKey,KeyAlgorithm.A128GCMKW); JweEncryptionProvider encryption=new AesCbcHmacJweEncryption(ContentAlgorithm.A128CBC_HS256,CONTENT_ENCRYPTION_KEY_A3,INIT_VECTOR_A3,keyEncryption); String jweContent=encryption.encrypt(specPlainText.getBytes(StandardCharsets.UTF_8),null); AesGcmWrapKeyDecryptionAlgorithm keyDecryption=new AesGcmWrapKeyDecryptionAlgorithm(cekEncryptionKey); JweDecryptionProvider decryption=new AesCbcHmacJweDecryption(keyDecryption); String decryptedText=decryption.decrypt(jweContent).getContentText(); assertEquals(specPlainText,decryptedText); }

InternalCallVerifier EqualityVerifier 
@Test public void testECDHESDirectKeyEncryption() throws Exception { ECPrivateKey bobPrivateKey=CryptoUtils.getECPrivateKey(JsonWebKey.EC_CURVE_P256,"VEmDZpDXXK8p8N0Cndsxs924q6nS1RXFASRl6BfUqdw"); final ECPublicKey bobPublicKey=CryptoUtils.getECPublicKey(JsonWebKey.EC_CURVE_P256,"weNJy2HscCSM6AEDTDg04biOvhFhyyWvOHQfeF_PxMQ","e8lnCO-AlStT-NJVX-crhB7QRYhiix03illJOVAOyck"); JweEncryptionProvider jweOut=new EcdhDirectKeyJweEncryption(bobPublicKey,JsonWebKey.EC_CURVE_P256,"Alice","Bob",ContentAlgorithm.A128GCM); String jweOutput=jweOut.encrypt("Hello".getBytes(),null); JweDecryptionProvider jweIn=new EcdhDirectKeyJweDecryption(bobPrivateKey,ContentAlgorithm.A128GCM); assertEquals("Hello",jweIn.decrypt(jweOutput).getContentText()); }

Class: org.apache.cxf.rs.security.jose.jwe.JweJsonConsumerTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testSingleRecipientAllTypeOfHeadersAndAad(){ final String text="The true sign of intelligence is not knowledge but imagination."; SecretKey wrapperKey=CryptoUtils.createSecretKeySpec(JweJsonProducerTest.WRAPPER_BYTES1,"AES"); JweDecryptionProvider jwe=JweUtils.createJweDecryptionProvider(wrapperKey,KeyAlgorithm.A128KW,ContentAlgorithm.A128GCM); JweJsonConsumer consumer=new JweJsonConsumer(JweJsonProducerTest.SINGLE_RECIPIENT_ALL_HEADERS_AAD_OUTPUT); JweDecryptionOutput out=consumer.decryptWith(jwe); assertEquals(text,out.getContentText()); assertEquals(JweJsonProducerTest.EXTRA_AAD_SOURCE,consumer.getAadText()); }

Class: org.apache.cxf.rs.security.jose.jwe.JweJsonProducerTest

InternalCallVerifier EqualityVerifier 
@Test public void testMultipleRecipients(){ final String text="The true sign of intelligence is not knowledge but imagination."; SecretKey wrapperKey1=CryptoUtils.createSecretKeySpec(WRAPPER_BYTES1,"AES"); SecretKey wrapperKey2=CryptoUtils.createSecretKeySpec(WRAPPER_BYTES2,"AES"); JweHeaders protectedHeaders=new JweHeaders(ContentAlgorithm.A128GCM); JweHeaders sharedUnprotectedHeaders=new JweHeaders(); sharedUnprotectedHeaders.setJsonWebKeysUrl("https://server.example.com/keys.jwks"); sharedUnprotectedHeaders.setKeyEncryptionAlgorithm(KeyAlgorithm.A128KW); List jweList=new LinkedList(); KeyEncryptionProvider keyEncryption1=JweUtils.getSecretKeyEncryptionAlgorithm(wrapperKey1,KeyAlgorithm.A128KW); ContentEncryptionProvider contentEncryption=JweUtils.getContentEncryptionProvider(ContentAlgorithm.A128GCM); JweEncryptionProvider jwe1=new JweEncryption(keyEncryption1,contentEncryption); KeyEncryptionProvider keyEncryption2=JweUtils.getSecretKeyEncryptionAlgorithm(wrapperKey2,KeyAlgorithm.A128KW); JweEncryptionProvider jwe2=new JweEncryption(keyEncryption2,contentEncryption); jweList.add(jwe1); jweList.add(jwe2); JweJsonProducer p=new JweJsonProducer(protectedHeaders,sharedUnprotectedHeaders,StringUtils.toBytesUTF8(text),StringUtils.toBytesUTF8(EXTRA_AAD_SOURCE),false){ protected JweEncryptionInput createEncryptionInput( JweHeaders jsonHeaders){ JweEncryptionInput input=super.createEncryptionInput(jsonHeaders); input.setCek(CEK_BYTES); input.setIv(JweCompactReaderWriterTest.INIT_VECTOR_A1); return input; } } ; String jweJson=p.encryptWith(jweList); assertEquals(MULTIPLE_RECIPIENTS_OUTPUT,jweJson); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testSingleRecipientAllTypeOfHeadersAndAad(){ final String text="The true sign of intelligence is not knowledge but imagination."; SecretKey wrapperKey=CryptoUtils.createSecretKeySpec(WRAPPER_BYTES1,"AES"); JweHeaders protectedHeaders=new JweHeaders(ContentAlgorithm.A128GCM); JweHeaders sharedUnprotectedHeaders=new JweHeaders(); sharedUnprotectedHeaders.setJsonWebKeysUrl("https://server.example.com/keys.jwks"); JweEncryptionProvider jwe=JweUtils.createJweEncryptionProvider(wrapperKey,KeyAlgorithm.A128KW,ContentAlgorithm.A128GCM,null); JweJsonProducer p=new JweJsonProducer(protectedHeaders,sharedUnprotectedHeaders,StringUtils.toBytesUTF8(text),StringUtils.toBytesUTF8(EXTRA_AAD_SOURCE),false){ protected JweEncryptionInput createEncryptionInput( JweHeaders jsonHeaders){ JweEncryptionInput input=super.createEncryptionInput(jsonHeaders); input.setCek(CEK_BYTES); input.setIv(JweCompactReaderWriterTest.INIT_VECTOR_A1); return input; } } ; JweHeaders recepientUnprotectedHeaders=new JweHeaders(); recepientUnprotectedHeaders.setKeyEncryptionAlgorithm(KeyAlgorithm.A128KW); String jweJson=p.encryptWith(jwe,recepientUnprotectedHeaders); assertEquals(SINGLE_RECIPIENT_ALL_HEADERS_AAD_OUTPUT,jweJson); }

Class: org.apache.cxf.rs.security.jose.jwe.JwePbeHmacAesWrapTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testEncryptDecryptPbesHmacAesWrapA128CBCHS256() throws Exception { final String specPlainText="Live long and prosper."; final String password="Thus from my lips, by yours, my sin is purged."; KeyEncryptionProvider keyEncryption=new PbesHmacAesWrapKeyEncryptionAlgorithm(password,KeyAlgorithm.PBES2_HS256_A128KW); JweEncryptionProvider encryption=new AesCbcHmacJweEncryption(ContentAlgorithm.A128CBC_HS256,keyEncryption); String jweContent=encryption.encrypt(specPlainText.getBytes(StandardCharsets.UTF_8),null); PbesHmacAesWrapKeyDecryptionAlgorithm keyDecryption=new PbesHmacAesWrapKeyDecryptionAlgorithm(password); JweDecryptionProvider decryption=new AesCbcHmacJweDecryption(keyDecryption); String decryptedText=decryption.decrypt(jweContent).getContentText(); assertEquals(specPlainText,decryptedText); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testEncryptDecryptPbesHmacAesWrapAesGcm() throws Exception { final String specPlainText="Live long and prosper."; JweHeaders headers=new JweHeaders(); headers.setKeyEncryptionAlgorithm(KeyAlgorithm.PBES2_HS256_A128KW); headers.setContentEncryptionAlgorithm(ContentAlgorithm.A128GCM); final String password="Thus from my lips, by yours, my sin is purged."; KeyEncryptionProvider keyEncryption=new PbesHmacAesWrapKeyEncryptionAlgorithm(password,KeyAlgorithm.PBES2_HS256_A128KW); JweEncryptionProvider encryption=new JweEncryption(keyEncryption,new AesGcmContentEncryptionAlgorithm(ContentAlgorithm.A128GCM)); String jweContent=encryption.encrypt(specPlainText.getBytes(StandardCharsets.UTF_8),null); PbesHmacAesWrapKeyDecryptionAlgorithm keyDecryption=new PbesHmacAesWrapKeyDecryptionAlgorithm(password); JweDecryptionProvider decryption=new JweDecryption(keyDecryption,new AesGcmContentDecryptionAlgorithm(ContentAlgorithm.A128GCM)); String decryptedText=decryption.decrypt(jweContent).getContentText(); assertEquals(specPlainText,decryptedText); }

Class: org.apache.cxf.rs.security.jose.jwk.JsonWebKeyTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testEncryptDecryptPrivateSet() throws Exception { final String password="Thus from my lips, by yours, my sin is purged."; Security.addProvider(new BouncyCastleProvider()); try { JsonWebKeys jwks=readKeySet("jwkPrivateSet.txt"); validatePrivateSet(jwks); String encryptedKeySet=JwkUtils.encryptJwkSet(jwks,password.toCharArray()); JweCompactConsumer c=new JweCompactConsumer(encryptedKeySet); assertEquals("jwk-set+json",c.getJweHeaders().getContentType()); assertEquals(KeyAlgorithm.PBES2_HS256_A128KW,c.getJweHeaders().getKeyEncryptionAlgorithm()); assertEquals(ContentAlgorithm.A128CBC_HS256,c.getJweHeaders().getContentEncryptionAlgorithm()); assertNotNull(c.getJweHeaders().getHeader("p2s")); assertNotNull(c.getJweHeaders().getHeader("p2c")); jwks=JwkUtils.decryptJwkSet(encryptedKeySet,password.toCharArray()); validatePrivateSet(jwks); } finally { Security.removeProvider(BouncyCastleProvider.PROVIDER_NAME); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testPublicSetAsList() throws Exception { JsonWebKeys jwks=readKeySet("jwkPublicSet.txt"); List keys=jwks.getKeys(); assertEquals(3,keys.size()); JsonWebKey ecKey=keys.get(0); assertEquals(6,ecKey.asMap().size()); validatePublicEcKey(ecKey); JsonWebKey rsaKey=keys.get(1); assertEquals(5,rsaKey.asMap().size()); validatePublicRsaKey(rsaKey); JsonWebKey rsaKeyCert=keys.get(2); assertEquals(3,rsaKeyCert.asMap().size()); assertEquals(3,rsaKeyCert.getX509Chain().size()); List certs=JwkUtils.toX509CertificateChain(rsaKeyCert); assertEquals(3,certs.size()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testPublicSetAsMap() throws Exception { JsonWebKeys jwks=readKeySet("jwkPublicSet.txt"); Map keysMap=jwks.getKeyIdMap(); assertEquals(3,keysMap.size()); JsonWebKey rsaKey=keysMap.get(RSA_KID_VALUE); assertEquals(5,rsaKey.asMap().size()); validatePublicRsaKey(rsaKey); JsonWebKey ecKey=keysMap.get(EC_KID_VALUE); assertEquals(6,ecKey.asMap().size()); validatePublicEcKey(ecKey); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testSecretSetAsList() throws Exception { JsonWebKeys jwks=readKeySet("jwkSecretSet.txt"); List keys=jwks.getKeys(); assertEquals(2,keys.size()); JsonWebKey aesKey=keys.get(0); assertEquals(4,aesKey.asMap().size()); validateSecretAesKey(aesKey); JsonWebKey hmacKey=keys.get(1); assertEquals(4,hmacKey.asMap().size()); validateSecretHmacKey(hmacKey); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testEncryptDecryptPrivateKey() throws Exception { final String password="Thus from my lips, by yours, my sin is purged."; final String key="{\"kty\":\"oct\"," + "\"alg\":\"A128KW\"," + "\"k\":\"GawgguFyGrWKav7AX4VKUg\","+ "\"kid\":\"AesWrapKey\"}"; Security.addProvider(new BouncyCastleProvider()); try { JsonWebKey jwk=readKey(key); validateSecretAesKey(jwk); String encryptedKey=JwkUtils.encryptJwkKey(jwk,password.toCharArray()); JweCompactConsumer c=new JweCompactConsumer(encryptedKey); assertEquals("jwk+json",c.getJweHeaders().getContentType()); assertEquals(KeyAlgorithm.PBES2_HS256_A128KW,c.getJweHeaders().getKeyEncryptionAlgorithm()); assertEquals(ContentAlgorithm.A128CBC_HS256,c.getJweHeaders().getContentEncryptionAlgorithm()); assertNotNull(c.getJweHeaders().getHeader("p2s")); assertNotNull(c.getJweHeaders().getHeader("p2c")); jwk=JwkUtils.decryptJwkKey(encryptedKey,password.toCharArray()); validateSecretAesKey(jwk); } finally { Security.removeProvider(BouncyCastleProvider.PROVIDER_NAME); } }

Class: org.apache.cxf.rs.security.jose.jwk.JwkUtilsTest

APIUtilityVerifier EqualityVerifier 
@Test public void testOctetKey1Thumbprint() throws Exception { String thumbprint=JwkUtils.getThumbprint(OCTET_KEY_1); assertEquals("7WWD36NF4WCpPaYtK47mM4o0a5CCeOt01JXSuMayv5g",thumbprint); }

APIUtilityVerifier EqualityVerifier 
@Test public void testEc384KeyThumbprint() throws Exception { String thumbprint=JwkUtils.getThumbprint(EC_384_KEY); assertEquals("vZtaWIw-zw95JNzzURg1YB7mWNLlm44YZDZzhrPNetM",thumbprint); }

APIUtilityVerifier EqualityVerifier 
@Test public void testEc521KeyThumbprint() throws Exception { String thumbprint=JwkUtils.getThumbprint(EC_521_KEY); assertEquals("rz4Ohmpxg-UOWIWqWKHlOe0bHSjNUFlHW5vwG_M7qYg",thumbprint); }

APIUtilityVerifier EqualityVerifier 
@Test public void testOctetKey2Thumbprint() throws Exception { String thumbprint=JwkUtils.getThumbprint(OCTET_KEY_2); assertEquals("5_qb56G0OJDw-lb5mkDaWS4MwuY0fatkn9LkNqUHqMk",thumbprint); }

APIUtilityVerifier EqualityVerifier 
@Test public void testRsaKeyThumbprint() throws Exception { String thumbprint=JwkUtils.getThumbprint(RSA_KEY); assertEquals("NzbLsXh8uDCcd-6MNwXF4W_7noWXFZAfHkxZsRGC9Xs",thumbprint); }

APIUtilityVerifier EqualityVerifier 
@Test public void testEc256KeyThumbprint() throws Exception { String thumbprint=JwkUtils.getThumbprint(EC_256_KEY); assertEquals("j4UYwo9wrtllSHaoLDJNh7MhVCL8t0t8cGPPzChpYDs",thumbprint); }

Class: org.apache.cxf.rs.security.jose.jws.JwsCompactReaderWriterTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testReadJwsWithJwkSignedByMac() throws Exception { JwsJwtCompactConsumer jws=new JwsJwtCompactConsumer(ENCODED_TOKEN_WITH_JSON_KEY_SIGNED_BY_MAC); assertTrue(jws.verifySignatureWith(new HmacJwsSignatureVerifier(ENCODED_MAC_KEY,SignatureAlgorithm.HS256))); JwtToken token=jws.getJwtToken(); JwsHeaders headers=new JwsHeaders(token.getJwsHeaders()); assertEquals(JoseType.JWT,headers.getType()); assertEquals(SignatureAlgorithm.HS256,headers.getSignatureAlgorithm()); JsonWebKey key=headers.getJsonWebKey(); assertEquals(KeyType.OCTET,key.getKeyType()); List keyOps=key.getKeyOperation(); assertEquals(2,keyOps.size()); assertEquals(KeyOperation.SIGN,keyOps.get(0)); assertEquals(KeyOperation.VERIFY,keyOps.get(1)); validateSpecClaim(token.getClaims()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testJwsPsSha() throws Exception { Security.addProvider(new BouncyCastleProvider()); try { JwsHeaders outHeaders=new JwsHeaders(); outHeaders.setSignatureAlgorithm(SignatureAlgorithm.PS256); JwsCompactProducer producer=initSpecJwtTokenWriter(outHeaders); PrivateKey privateKey=CryptoUtils.getRSAPrivateKey(RSA_MODULUS_ENCODED,RSA_PRIVATE_EXPONENT_ENCODED); String signed=producer.signWith(new PrivateKeyJwsSignatureProvider(privateKey,SignatureAlgorithm.PS256)); JwsJwtCompactConsumer jws=new JwsJwtCompactConsumer(signed); RSAPublicKey key=CryptoUtils.getRSAPublicKey(RSA_MODULUS_ENCODED,RSA_PUBLIC_EXPONENT_ENCODED); assertTrue(jws.verifySignatureWith(new PublicKeyJwsSignatureVerifier(key,SignatureAlgorithm.PS256))); JwtToken token=jws.getJwtToken(); JwsHeaders inHeaders=new JwsHeaders(token.getJwsHeaders()); assertEquals(SignatureAlgorithm.PS256,inHeaders.getSignatureAlgorithm()); validateSpecClaim(token.getClaims()); } finally { Security.removeProvider(BouncyCastleProvider.PROVIDER_NAME); } }

InternalCallVerifier EqualityVerifier 
@Test public void testWriteReadJwsUnsigned() throws Exception { JwsHeaders headers=new JwsHeaders(JoseType.JWT); headers.setSignatureAlgorithm(SignatureAlgorithm.NONE); JwtClaims claims=new JwtClaims(); claims.setIssuer("https://jwt-idp.example.com"); claims.setSubject("mailto:mike@example.com"); claims.setAudiences(Collections.singletonList("https://jwt-rp.example.net")); claims.setNotBefore(1300815780L); claims.setExpiryTime(1300819380L); claims.setClaim("http://claims.example.com/member",true); JwsCompactProducer writer=new JwsJwtCompactProducer(headers,claims); String signed=writer.getSignedEncodedJws(); JwsJwtCompactConsumer reader=new JwsJwtCompactConsumer(signed); assertEquals(0,reader.getDecodedSignature().length); JwtToken token=reader.getJwtToken(); assertEquals(new JwtToken(headers,claims),token); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testReadJwsSignedByPrivateKey() throws Exception { JwsJwtCompactConsumer jws=new JwsJwtCompactConsumer(ENCODED_TOKEN_SIGNED_BY_PRIVATE_KEY); RSAPublicKey key=CryptoUtils.getRSAPublicKey(RSA_MODULUS_ENCODED,RSA_PUBLIC_EXPONENT_ENCODED); assertTrue(jws.verifySignatureWith(new PublicKeyJwsSignatureVerifier(key,SignatureAlgorithm.RS256))); JwtToken token=jws.getJwtToken(); JwsHeaders headers=new JwsHeaders(token.getJwsHeaders()); assertEquals(SignatureAlgorithm.RS256,headers.getSignatureAlgorithm()); validateSpecClaim(token.getClaims()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testWriteReadJwsUnencodedPayload() throws Exception { JwsHeaders headers=new JwsHeaders(SignatureAlgorithm.HS256); headers.setPayloadEncodingStatus(false); JwsCompactProducer producer=new JwsCompactProducer(headers,UNSIGNED_PLAIN_DOCUMENT,true); producer.signWith(new HmacJwsSignatureProvider(ENCODED_MAC_KEY,SignatureAlgorithm.HS256)); assertEquals(TOKEN_WITH_DETACHED_UNENCODED_PAYLOAD,producer.getSignedEncodedJws()); JwsCompactConsumer consumer=new JwsCompactConsumer(TOKEN_WITH_DETACHED_UNENCODED_PAYLOAD,UNSIGNED_PLAIN_DOCUMENT); assertTrue(consumer.verifySignatureWith(new HmacJwsSignatureVerifier(ENCODED_MAC_KEY,SignatureAlgorithm.HS256))); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testWriteReadJwsSignedByESPrivateKey() throws Exception { JwsHeaders headers=new JwsHeaders(); headers.setSignatureAlgorithm(SignatureAlgorithm.ES256); JwsCompactProducer jws=initSpecJwtTokenWriter(headers); ECPrivateKey privateKey=CryptoUtils.getECPrivateKey(JsonWebKey.EC_CURVE_P256,EC_PRIVATE_KEY_ENCODED); jws.signWith(new EcDsaJwsSignatureProvider(privateKey,SignatureAlgorithm.ES256)); String signedJws=jws.getSignedEncodedJws(); ECPublicKey publicKey=CryptoUtils.getECPublicKey(JsonWebKey.EC_CURVE_P256,EC_X_POINT_ENCODED,EC_Y_POINT_ENCODED); JwsJwtCompactConsumer jwsConsumer=new JwsJwtCompactConsumer(signedJws); assertTrue(jwsConsumer.verifySignatureWith(new EcDsaJwsSignatureVerifier(publicKey,SignatureAlgorithm.ES256))); JwtToken token=jwsConsumer.getJwtToken(); JwsHeaders headersReceived=new JwsHeaders(token.getJwsHeaders()); assertEquals(SignatureAlgorithm.ES256,headersReceived.getSignatureAlgorithm()); validateSpecClaim(token.getClaims()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testReadJwsSignedByMacSpecExample() throws Exception { JwsJwtCompactConsumer jws=new JwsJwtCompactConsumer(ENCODED_TOKEN_SIGNED_BY_MAC); assertTrue(jws.verifySignatureWith(new HmacJwsSignatureVerifier(ENCODED_MAC_KEY,SignatureAlgorithm.HS256))); JwtToken token=jws.getJwtToken(); JwsHeaders headers=new JwsHeaders(token.getJwsHeaders()); assertEquals(JoseType.JWT,headers.getType()); assertEquals(SignatureAlgorithm.HS256,headers.getSignatureAlgorithm()); validateSpecClaim(token.getClaims()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testWriteJwsSignedByMacSpecExample() throws Exception { JwsHeaders headers=new JwsHeaders(); headers.setType(JoseType.JWT); headers.setSignatureAlgorithm(SignatureAlgorithm.HS256); JwsCompactProducer jws=initSpecJwtTokenWriter(headers); jws.signWith(new HmacJwsSignatureProvider(ENCODED_MAC_KEY,SignatureAlgorithm.HS256)); assertEquals(ENCODED_TOKEN_SIGNED_BY_MAC,jws.getSignedEncodedJws()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testWriteJwsSignedByPrivateKey() throws Exception { JwsHeaders headers=new JwsHeaders(); headers.setSignatureAlgorithm(SignatureAlgorithm.RS256); JwsCompactProducer jws=initSpecJwtTokenWriter(headers); PrivateKey key=CryptoUtils.getRSAPrivateKey(RSA_MODULUS_ENCODED,RSA_PRIVATE_EXPONENT_ENCODED); jws.signWith(new PrivateKeyJwsSignatureProvider(key,SignatureAlgorithm.RS256)); assertEquals(ENCODED_TOKEN_SIGNED_BY_PRIVATE_KEY,jws.getSignedEncodedJws()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testNoneSignature() throws Exception { JwtClaims claims=new JwtClaims(); claims.setClaim("a","b"); JwsJwtCompactProducer producer=new JwsJwtCompactProducer(claims); producer.signWith(new NoneJwsSignatureProvider()); JwsJwtCompactConsumer consumer=new JwsJwtCompactConsumer(producer.getSignedEncodedJws()); assertTrue(consumer.verifySignatureWith(new NoneJwsSignatureVerifier())); JwtClaims claims2=consumer.getJwtClaims(); assertEquals(claims,claims2); }

Class: org.apache.cxf.rs.security.jose.jws.JwsJsonConsumerTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testVerifyDualSignedDocument() throws Exception { JwsJsonConsumer consumer=new JwsJsonConsumer(DUAL_SIGNED_DOCUMENT); JsonWebKeys jwks=readKeySet("jwkPublicJsonConsumerSet.txt"); List sigEntries=consumer.getSignatureEntries(); assertEquals(2,sigEntries.size()); String firstKid=(String)sigEntries.get(0).getKeyId(); assertEquals(KID_OF_THE_FIRST_SIGNER,firstKid); JsonWebKey rsaKey=jwks.getKey(firstKid); assertNotNull(rsaKey); assertTrue(sigEntries.get(0).verifySignatureWith(rsaKey)); String secondKid=(String)sigEntries.get(1).getKeyId(); assertEquals(KID_OF_THE_SECOND_SIGNER,secondKid); JsonWebKey ecKey=jwks.getKey(secondKid); assertNotNull(ecKey); assertTrue(sigEntries.get(1).verifySignatureWith(ecKey)); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testVerifySignedWithProtectedHeaderOnlyUnencodedPayload(){ JwsJsonConsumer consumer=new JwsJsonConsumer(JwsJsonProducerTest.SIGNED_JWS_JSON_FLAT_UNENCODED_DOCUMENT); assertEquals(JwsJsonProducerTest.UNSIGNED_PLAIN_DOCUMENT,consumer.getJwsPayload()); assertEquals(JwsJsonProducerTest.UNSIGNED_PLAIN_DOCUMENT,consumer.getDecodedJwsPayload()); assertTrue(consumer.verifySignatureWith(new HmacJwsSignatureVerifier(JwsJsonProducerTest.ENCODED_MAC_KEY_1,SignatureAlgorithm.HS256))); }

Class: org.apache.cxf.rs.security.jose.jws.JwsJsonProducerTest

InternalCallVerifier EqualityVerifier 
@Test public void testDualSignWithProtectedHeaderOnly(){ JwsJsonProducer producer=new JwsJsonProducer(UNSIGNED_PLAIN_JSON_DOCUMENT); JwsHeaders headerEntries=new JwsHeaders(); headerEntries.setSignatureAlgorithm(SignatureAlgorithm.HS256); producer.signWith(new HmacJwsSignatureProvider(ENCODED_MAC_KEY_1,SignatureAlgorithm.HS256),headerEntries); producer.signWith(new HmacJwsSignatureProvider(ENCODED_MAC_KEY_2,SignatureAlgorithm.HS256),headerEntries); assertEquals(DUAL_SIGNED_JWS_JSON_DOCUMENT,producer.getJwsJsonSignedDocument()); }

InternalCallVerifier EqualityVerifier 
@Test public void testSignWithProtectedHeaderOnlyFlat(){ JwsJsonProducer producer=new JwsJsonProducer(UNSIGNED_PLAIN_JSON_DOCUMENT,true); JwsHeaders headerEntries=new JwsHeaders(); headerEntries.setSignatureAlgorithm(SignatureAlgorithm.HS256); producer.signWith(new HmacJwsSignatureProvider(ENCODED_MAC_KEY_1,SignatureAlgorithm.HS256),headerEntries); assertEquals(SIGNED_JWS_JSON_FLAT_DOCUMENT,producer.getJwsJsonSignedDocument()); }

InternalCallVerifier EqualityVerifier 
@Test public void testSignWithProtectedHeaderOnly(){ JwsJsonProducer producer=new JwsJsonProducer(UNSIGNED_PLAIN_JSON_DOCUMENT); JwsHeaders headerEntries=new JwsHeaders(); headerEntries.setSignatureAlgorithm(SignatureAlgorithm.HS256); producer.signWith(new HmacJwsSignatureProvider(ENCODED_MAC_KEY_1,SignatureAlgorithm.HS256),headerEntries); assertEquals(SIGNED_JWS_JSON_DOCUMENT,producer.getJwsJsonSignedDocument()); }

EqualityVerifier 
@Test public void testSignPlainJsonDocumentPayloadConstruction(){ JwsJsonProducer producer=new JwsJsonProducer(UNSIGNED_PLAIN_JSON_DOCUMENT); assertEquals(UNSIGNED_PLAIN_JSON_DOCUMENT_AS_B64URL,producer.getUnsignedEncodedPayload()); }

InternalCallVerifier EqualityVerifier 
@Test public void testSignWithProtectedHeaderOnlyUnencodedPayload(){ JwsJsonProducer producer=new JwsJsonProducer(UNSIGNED_PLAIN_DOCUMENT,true); JwsHeaders headers=new JwsHeaders(); headers.setSignatureAlgorithm(SignatureAlgorithm.HS256); headers.setPayloadEncodingStatus(false); producer.signWith(new HmacJwsSignatureProvider(ENCODED_MAC_KEY_1,SignatureAlgorithm.HS256),headers); assertEquals(SIGNED_JWS_JSON_FLAT_UNENCODED_DOCUMENT,producer.getJwsJsonSignedDocument()); }

Class: org.apache.cxf.rs.security.jose.jws.JwsUtilsTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testLoadVerificationKeys() throws Exception { Properties p=new Properties(); p.put(JoseConstants.RSSEC_KEY_STORE_FILE,"org/apache/cxf/rs/security/jose/jws/alice.jks"); p.put(JoseConstants.RSSEC_KEY_STORE_PSWD,"password"); p.put(JoseConstants.RSSEC_KEY_STORE_ALIAS,"alice"); JsonWebKeys keySet=JwsUtils.loadPublicVerificationKeys(createMessage(),p); assertEquals(1,keySet.asMap().size()); List keys=keySet.getRsaKeys(); assertEquals(1,keys.size()); JsonWebKey key=keys.get(0); assertEquals(KeyType.RSA,key.getKeyType()); assertEquals("alice",key.getKeyId()); assertNotNull(key.getKeyProperty(JsonWebKey.RSA_PUBLIC_EXP)); assertNotNull(key.getKeyProperty(JsonWebKey.RSA_MODULUS)); assertNull(key.getKeyProperty(JsonWebKey.RSA_PRIVATE_EXP)); }

Class: org.apache.cxf.rs.security.oauth2.grants.TokenGrantHandlerTest

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testSimpleGrantBug(){ try { new SimpleGrantHandler(Arrays.asList("a","b")).createAccessToken(createClient("a"),createMap("a")); fail("Grant handler bug"); } catch ( WebApplicationException ex) { assertEquals(500,ex.getResponse().getStatus()); } }

Class: org.apache.cxf.rs.security.oauth2.provider.OAuthJSONProviderTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test @SuppressWarnings({"unchecked","rawtypes"}) public void testReadTokenIntrospection() throws Exception { String response="{\"active\":true,\"client_id\":\"WjcK94pnec7CyA\",\"username\":\"alice\",\"token_type\":\"Bearer\"" + ",\"scope\":\"a\",\"aud\":\"https://localhost:8082/service\"," + "\"iat\":1453472181,\"exp\":1453475781}"; OAuthJSONProvider provider=new OAuthJSONProvider(); TokenIntrospection t=(TokenIntrospection)provider.readFrom((Class)TokenIntrospection.class,TokenIntrospection.class,new Annotation[]{},MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),new ByteArrayInputStream(response.getBytes())); assertTrue(t.isActive()); assertEquals("WjcK94pnec7CyA",t.getClientId()); assertEquals("alice",t.getUsername()); assertEquals("a",t.getScope()); assertEquals(1,t.getAud().size()); assertEquals("https://localhost:8082/service",t.getAud().get(0)); assertEquals(1453472181L,t.getIat().longValue()); assertEquals(1453475781L,t.getExp().longValue()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test @SuppressWarnings({"unchecked","rawtypes"}) public void testReadTokenIntrospectionMultipleAuds() throws Exception { String response="{\"active\":true,\"client_id\":\"WjcK94pnec7CyA\",\"username\":\"alice\",\"token_type\":\"Bearer\"" + ",\"scope\":\"a\",\"aud\":[\"https://localhost:8082/service\",\"https://localhost:8083/service\"]," + "\"iat\":1453472181,\"exp\":1453475781}"; OAuthJSONProvider provider=new OAuthJSONProvider(); TokenIntrospection t=(TokenIntrospection)provider.readFrom((Class)TokenIntrospection.class,TokenIntrospection.class,new Annotation[]{},MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),new ByteArrayInputStream(response.getBytes())); assertTrue(t.isActive()); assertEquals("WjcK94pnec7CyA",t.getClientId()); assertEquals("alice",t.getUsername()); assertEquals("a",t.getScope()); assertEquals(2,t.getAud().size()); assertEquals("https://localhost:8082/service",t.getAud().get(0)); assertEquals("https://localhost:8083/service",t.getAud().get(1)); assertEquals(1453472181L,t.getIat().longValue()); assertEquals(1453475781L,t.getExp().longValue()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test @SuppressWarnings({"unchecked","rawtypes"}) public void testReadTokenIntrospectionSingleAudAsArray() throws Exception { String response="{\"active\":false,\"client_id\":\"WjcK94pnec7CyA\",\"username\":\"alice\",\"token_type\":\"Bearer\"" + ",\"scope\":\"a\",\"aud\":[\"https://localhost:8082/service\"]," + "\"iat\":1453472181,\"exp\":1453475781}"; OAuthJSONProvider provider=new OAuthJSONProvider(); TokenIntrospection t=(TokenIntrospection)provider.readFrom((Class)TokenIntrospection.class,TokenIntrospection.class,new Annotation[]{},MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),new ByteArrayInputStream(response.getBytes())); assertFalse(t.isActive()); assertEquals("WjcK94pnec7CyA",t.getClientId()); assertEquals("alice",t.getUsername()); assertEquals("a",t.getScope()); assertEquals(1,t.getAud().size()); assertEquals("https://localhost:8082/service",t.getAud().get(0)); assertEquals(1453472181L,t.getIat().longValue()); assertEquals(1453475781L,t.getExp().longValue()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testReadHawkClientAccessToken() throws Exception { String response="{" + "\"access_token\":\"1234\"," + "\"token_type\":\"hawk\","+ "\"refresh_token\":\"5678\","+ "\"expires_in\":12345,"+ "\"scope\":\"read\","+ "\"secret\":\"adijq39jdlaska9asud\","+ "\"algorithm\":\"hmac-sha-256\","+ "\"my_parameter\":\"http://abc\""+ "}"; ClientAccessToken macToken=doReadClientAccessToken(response,"hawk",null); assertEquals("adijq39jdlaska9asud",macToken.getParameters().get(OAuthConstants.HAWK_TOKEN_KEY)); assertEquals("hmac-sha-256",macToken.getParameters().get(OAuthConstants.HAWK_TOKEN_ALGORITHM)); }

Class: org.apache.cxf.rs.security.oauth2.tokens.hawk.NonceVerifierImplTest

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testVerifyNonceInvalidTimestamp(){ long now=System.currentTimeMillis(); Nonce nonce1=new Nonce("nonce1",now - 2000); Nonce nonce2=new Nonce("nonce2",now - 1000); NonceHistory nonceHistory=new NonceHistory(200,nonce1); nonceHistory.addNonce(nonce2); EasyMock.expect(nonceStore.getNonceHistory("testTokenKey")).andReturn(nonceHistory); EasyMock.replay(nonceStore); nonceVerifier.setAllowedWindow(2000); try { nonceVerifier.verifyNonce("testTokenKey","nonce3",Long.toString(now - 5000)); fail("Exception expected"); } catch ( OAuthServiceException ex) { assertEquals("Timestamp is invalid",ex.getMessage()); } }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testVerifyNonceDuplicateNonce(){ long now=System.currentTimeMillis(); Nonce nonce1=new Nonce("nonce1",now - 2000); Nonce nonce2=new Nonce("nonce2",now - 1000); NonceHistory nonceHistory=new NonceHistory(200,nonce1); nonceHistory.addNonce(nonce2); EasyMock.expect(nonceStore.getNonceHistory("testTokenKey")).andReturn(nonceHistory); EasyMock.replay(nonceStore); nonceVerifier.setAllowedWindow(2000); try { nonceVerifier.verifyNonce("testTokenKey","nonce2",Long.toString(now - 1000)); fail("Exception expected"); } catch ( OAuthServiceException ex) { assertEquals("Duplicate nonce",ex.getMessage()); } }

Class: org.apache.cxf.rs.security.oauth2.utils.AuthorizationUtilsTest

UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testThrowAuthorizationFailureSingleChallenge(){ try { AuthorizationUtils.throwAuthorizationFailure(Collections.singleton("Basic")); fail("WebApplicationException expected"); } catch ( WebApplicationException ex) { Response r=ex.getResponse(); assertEquals(401,r.getStatus()); Object value=r.getMetadata().getFirst(HttpHeaders.WWW_AUTHENTICATE); assertNotNull(value); assertEquals("Basic",value.toString()); } }

UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testThrowAuthorizationFailureNoChallenge(){ try { AuthorizationUtils.throwAuthorizationFailure(Collections.emptySet()); fail("WebApplicationException expected"); } catch ( WebApplicationException ex) { Response r=ex.getResponse(); assertEquals(401,r.getStatus()); Object value=r.getMetadata().getFirst(HttpHeaders.WWW_AUTHENTICATE); assertNull(value); } }

UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testThrowAuthorizationFailureManyChallenges(){ Set challenges=new LinkedHashSet(); challenges.add("Basic"); challenges.add("Bearer"); try { AuthorizationUtils.throwAuthorizationFailure(challenges); fail("WebApplicationException expected"); } catch ( WebApplicationException ex) { Response r=ex.getResponse(); assertEquals(401,r.getStatus()); Object value=r.getMetadata().getFirst(HttpHeaders.WWW_AUTHENTICATE); assertNotNull(value); assertEquals("Basic,Bearer",value.toString()); } }

Class: org.apache.cxf.rs.security.oauth2.utils.crypto.CryptoUtilsTest

InternalCallVerifier EqualityVerifier 
@Test public void testEncryptDecryptCodeGrant() throws Exception { AuthorizationCodeRegistration codeReg=new AuthorizationCodeRegistration(); codeReg.setAudience("http://bar"); codeReg.setClient(p.getClient("1")); ServerAuthorizationCodeGrant grant=p.createCodeGrant(codeReg); ServerAuthorizationCodeGrant grant2=p.removeCodeGrant(grant.getCode()); assertEquals("http://bar",grant2.getAudience()); assertEquals("1",grant2.getClient().getClientId()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier PublicFieldVerifier HybridVerifier 
@Test public void testClientJSON() throws Exception { Client c=new Client("client","secret",true); c.setSubject(new UserSubject("subject","id")); JSONProvider jsonp=new JSONProvider(); jsonp.setMarshallAsJaxbElement(true); jsonp.setUnmarshallAsJaxbElement(true); ByteArrayOutputStream bos=new ByteArrayOutputStream(); jsonp.writeTo(c,Client.class,new Annotation[]{},MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),bos); String encrypted=CryptoUtils.encryptSequence(bos.toString(),p.key); String decrypted=CryptoUtils.decryptSequence(encrypted,p.key); Client c2=jsonp.readFrom(Client.class,Client.class,new Annotation[]{},MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),new ByteArrayInputStream(decrypted.getBytes())); assertEquals(c.getClientId(),c2.getClientId()); assertEquals(c.getClientSecret(),c2.getClientSecret()); assertTrue(c2.isConfidential()); assertEquals("subject",c2.getSubject().getLogin()); assertEquals("id",c2.getSubject().getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier PublicFieldVerifier 
@Test public void testCodeGrantJSON() throws Exception { Client c=new Client("client","secret",true); ServerAuthorizationCodeGrant grant=new ServerAuthorizationCodeGrant(c,"code",1,2); JSONProvider jsonp=new JSONProvider(); jsonp.setMarshallAsJaxbElement(true); jsonp.setUnmarshallAsJaxbElement(true); ByteArrayOutputStream bos=new ByteArrayOutputStream(); jsonp.writeTo(grant,ServerAuthorizationCodeGrant.class,new Annotation[]{},MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),bos); String encrypted=CryptoUtils.encryptSequence(bos.toString(),p.key); String decrypted=CryptoUtils.decryptSequence(encrypted,p.key); ServerAuthorizationCodeGrant grant2=jsonp.readFrom(ServerAuthorizationCodeGrant.class,Client.class,new Annotation[]{},MediaType.APPLICATION_JSON_TYPE,new MetadataMap(),new ByteArrayInputStream(decrypted.getBytes())); assertEquals("code",grant2.getCode()); assertEquals(1,grant2.getExpiresIn()); assertEquals(2,grant2.getIssuedAt()); }

Class: org.apache.cxf.rs.security.saml.DeflateEncoderDecoderTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testInflateDeflate() throws Exception { DeflateEncoderDecoder inflater=new DeflateEncoderDecoder(); byte[] deflated=inflater.deflateToken("valid_grant".getBytes()); InputStream is=inflater.inflateToken(deflated); assertNotNull(is); assertEquals("valid_grant",IOUtils.readStringFromStream(is)); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testInflateDeflateWithTokenDuplication() throws Exception { String token="valid_grant valid_grant valid_grant valid_grant valid_grant valid_grant"; DeflateEncoderDecoder deflateEncoderDecoder=new DeflateEncoderDecoder(); byte[] deflatedToken=deflateEncoderDecoder.deflateToken(token.getBytes()); String cxfInflatedToken=IOUtils.toString(deflateEncoderDecoder.inflateToken(deflatedToken)); String streamInflatedToken=IOUtils.toString(new InflaterInputStream(new ByteArrayInputStream(deflatedToken),new Inflater(true))); assertEquals(streamInflatedToken,token); assertEquals(cxfInflatedToken,token); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testInflateDeflateBase64() throws Exception { DeflateEncoderDecoder inflater=new DeflateEncoderDecoder(); byte[] deflated=inflater.deflateToken("valid_grant".getBytes()); String base64String=Base64Utility.encode(deflated); byte[] base64decoded=Base64Utility.decode(base64String); InputStream is=inflater.inflateToken(base64decoded); assertNotNull(is); assertEquals("valid_grant",IOUtils.readStringFromStream(is)); }

Class: org.apache.cxf.rs.security.saml.sso.EHCacheUtilTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCreateCacheManager(){ Configuration conf=ConfigurationFactory.parseConfiguration(EHCacheUtil.class.getResource("/cxf-test-ehcache.xml")); assertNotNull(conf); conf.setName("testCache"); CacheManager manager1=EHCacheUtil.createCacheManager(conf); assertNotNull(manager1); CacheManager manager2=EHCacheUtil.createCacheManager(); assertNotNull(manager2); manager1.shutdown(); assertEquals(Status.STATUS_SHUTDOWN,manager1.getStatus()); assertEquals(Status.STATUS_ALIVE,manager2.getStatus()); manager2.shutdown(); assertEquals(Status.STATUS_SHUTDOWN,manager2.getStatus()); }

Class: org.apache.cxf.rt.security.claims.ClaimTest

InternalCallVerifier EqualityVerifier 
@Test public void testCloneAllEquals(){ Claim claim=new Claim(); claim.setClaimType(URI.create("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/role")); claim.setOptional(true); claim.addValue("value1"); claim.addValue("value2"); claim.addValue("value3"); Claim clone=claim.clone(); assertEquals(claim,clone); assertEquals(claim,new Claim(clone)); }

InternalCallVerifier EqualityVerifier 
@Test public void testCloneValuesOnlySetEquals(){ Claim claim=new Claim(); claim.addValue("value1"); claim.addValue("value2"); Claim clone=claim.clone(); assertEquals(claim,clone); assertEquals(claim,new Claim(clone)); }

InternalCallVerifier EqualityVerifier 
@Test public void testCloneAndModifyValuesNotEquals(){ Claim claim=new Claim(); claim.setClaimType(URI.create("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/role")); claim.setOptional(true); claim.addValue("value1"); claim.addValue("value2"); claim.addValue("value3"); Claim clone=claim.clone(); claim.getValues().clear(); claim.addValue("value4"); assertNotEquals(claim,clone); assertEquals(1,claim.getValues().size()); assertEquals(3,clone.getValues().size()); assertEquals(claim.getClaimType(),clone.getClaimType()); assertEquals(claim.isOptional(),clone.isOptional()); assertNotEquals(claim.getValues(),clone.getValues()); }

InternalCallVerifier EqualityVerifier 
@Test public void testCloneAndModifyTypeNotEquals(){ Claim claim=new Claim(); claim.setClaimType(URI.create("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/role")); claim.setOptional(true); claim.addValue("value1"); claim.addValue("value2"); claim.addValue("value3"); Claim clone=claim.clone(); clone.setClaimType(URI.create("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/value")); assertNotEquals(claim,clone); assertNotEquals(claim.getClaimType(),clone.getClaimType()); assertEquals(claim.isOptional(),clone.isOptional()); assertEquals(claim.getValues(),clone.getValues()); }

InternalCallVerifier EqualityVerifier 
@Test public void testCloneUnset(){ Claim claim=new Claim(); Claim clone=claim.clone(); assertEquals(claim,clone); assertEquals(claim,new Claim(clone)); }

InternalCallVerifier EqualityVerifier 
@Test public void testCloneTypeOnlySetEquals(){ Claim claim=new Claim(); claim.setClaimType(URI.create("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/role")); Claim clone=claim.clone(); assertEquals(claim,clone); assertEquals(claim,new Claim(clone)); }

Class: org.apache.cxf.service.factory.ClientFactoryBeanTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testClientFactoryBean() throws Exception { ClientFactoryBean cfBean=new ClientFactoryBean(); cfBean.setAddress("http://localhost/Hello"); cfBean.setBus(getBus()); cfBean.setServiceClass(HelloService.class); Client client=cfBean.create(); assertNotNull(client); Service service=client.getEndpoint().getService(); Map eps=service.getEndpoints(); assertEquals(1,eps.size()); Endpoint ep=eps.values().iterator().next(); EndpointInfo endpointInfo=ep.getEndpointInfo(); BindingInfo b=endpointInfo.getService().getBindings().iterator().next(); assertTrue(b instanceof SoapBindingInfo); SoapBindingInfo sb=(SoapBindingInfo)b; assertEquals("HelloServiceSoapBinding",b.getName().getLocalPart()); assertEquals("document",sb.getStyle()); assertEquals(4,b.getOperations().size()); BindingOperationInfo bop=b.getOperations().iterator().next(); SoapOperationInfo sop=bop.getExtensor(SoapOperationInfo.class); assertNotNull(sop); assertEquals("",sop.getAction()); assertEquals("document",sop.getStyle()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testJaxbExtraClass() throws Exception { ClientFactoryBean cfBean=new ClientFactoryBean(); cfBean.setAddress("http://localhost/Hello"); cfBean.setBus(getBus()); cfBean.setServiceClass(HelloService.class); Map props=cfBean.getProperties(); if (props == null) { props=new HashMap(); } props.put("jaxb.additionalContextClasses",new Class[]{GreetMe.class,GreetMeOneWay.class}); cfBean.setProperties(props); Client client=cfBean.create(); assertNotNull(client); Class[] extraClass=((JAXBDataBinding)cfBean.getServiceFactory().getDataBinding()).getExtraClass(); assertEquals(extraClass.length,2); assertEquals(extraClass[0],GreetMe.class); assertEquals(extraClass[1],GreetMeOneWay.class); }

Class: org.apache.cxf.service.factory.ReflectionServiceFactoryTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testUnwrappedBuild() throws Exception { Service service=createService(false); ServiceInfo si=service.getServiceInfos().get(0); InterfaceInfo intf=si.getInterface(); assertEquals(4,intf.getOperations().size()); String ns=si.getName().getNamespaceURI(); OperationInfo sayHelloOp=intf.getOperation(new QName(ns,"sayHello")); assertNotNull(sayHelloOp); assertEquals("sayHello",sayHelloOp.getInput().getName().getLocalPart()); List messageParts=sayHelloOp.getInput().getMessageParts(); assertEquals(0,messageParts.size()); messageParts=sayHelloOp.getOutput().getMessageParts(); assertEquals(1,messageParts.size()); assertEquals("sayHelloResponse",sayHelloOp.getOutput().getName().getLocalPart()); MessagePartInfo mpi=messageParts.get(0); assertEquals("return",mpi.getName().getLocalPart()); assertEquals(String.class,mpi.getTypeClass()); OperationInfo op=si.getInterface().getOperation(new QName(ns,"echoWithExchange")); assertEquals(1,op.getInput().getMessageParts().size()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testServerFactoryBean() throws Exception { Service service=createService(true); assertEquals("test",service.get("test")); ServerFactoryBean svrBean=new ServerFactoryBean(); svrBean.setAddress("http://localhost/Hello"); svrBean.setServiceFactory(serviceFactory); svrBean.setServiceBean(new HelloServiceImpl()); svrBean.setBus(getBus()); Map props=new HashMap(); props.put("test","test"); serviceFactory.setProperties(props); svrBean.setProperties(props); Server server=svrBean.create(); assertNotNull(server); Map eps=service.getEndpoints(); assertEquals(1,eps.size()); Endpoint ep=eps.values().iterator().next(); EndpointInfo endpointInfo=ep.getEndpointInfo(); assertEquals("test",ep.get("test")); BindingInfo b=endpointInfo.getService().getBindings().iterator().next(); assertTrue(b instanceof SoapBindingInfo); SoapBindingInfo sb=(SoapBindingInfo)b; assertEquals("HelloServiceSoapBinding",b.getName().getLocalPart()); assertEquals("document",sb.getStyle()); assertEquals(4,b.getOperations().size()); BindingOperationInfo bop=b.getOperations().iterator().next(); SoapOperationInfo sop=bop.getExtensor(SoapOperationInfo.class); assertNotNull(sop); assertEquals("",sop.getAction()); assertEquals("document",sop.getStyle()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testWrappedBuild() throws Exception { Service service=createService(true); ServiceInfo si=service.getServiceInfos().get(0); InterfaceInfo intf=si.getInterface(); assertEquals(4,intf.getOperations().size()); String ns=si.getName().getNamespaceURI(); OperationInfo sayHelloOp=intf.getOperation(new QName(ns,"sayHello")); assertNotNull(sayHelloOp); assertEquals("sayHello",sayHelloOp.getInput().getName().getLocalPart()); List messageParts=sayHelloOp.getInput().getMessageParts(); assertEquals(1,messageParts.size()); assertNotNull(messageParts.get(0).getXmlSchema()); assertTrue(sayHelloOp.isUnwrappedCapable()); OperationInfo unwrappedOp=sayHelloOp.getUnwrappedOperation(); assertEquals("sayHello",unwrappedOp.getInput().getName().getLocalPart()); messageParts=unwrappedOp.getInput().getMessageParts(); assertEquals(0,messageParts.size()); messageParts=sayHelloOp.getOutput().getMessageParts(); assertEquals(1,messageParts.size()); assertEquals("sayHelloResponse",sayHelloOp.getOutput().getName().getLocalPart()); messageParts=unwrappedOp.getOutput().getMessageParts(); assertEquals("sayHelloResponse",unwrappedOp.getOutput().getName().getLocalPart()); assertEquals(1,messageParts.size()); MessagePartInfo mpi=messageParts.get(0); assertEquals("return",mpi.getName().getLocalPart()); assertEquals(String.class,mpi.getTypeClass()); }

Class: org.apache.cxf.service.factory.RountripTest

InternalCallVerifier EqualityVerifier 
@Test public void testServerFactoryBean() throws Exception { ServerFactoryBean svrBean=new ServerFactoryBean(); svrBean.setAddress("http://localhost/Hello"); svrBean.setTransportId("http://schemas.xmlsoap.org/soap/http"); svrBean.setServiceBean(new HelloServiceImpl()); svrBean.setServiceClass(HelloService.class); svrBean.setBus(getBus()); svrBean.create(); ClientProxyFactoryBean proxyFactory=new ClientProxyFactoryBean(); ClientFactoryBean clientBean=proxyFactory.getClientFactoryBean(); clientBean.setAddress("http://localhost/Hello"); clientBean.setTransportId("http://schemas.xmlsoap.org/soap/http"); clientBean.setServiceClass(HelloService.class); clientBean.setBus(getBus()); clientBean.getInInterceptors().add(new LoggingInInterceptor()); HelloService client=(HelloService)proxyFactory.create(); ClientImpl c=(ClientImpl)ClientProxy.getClient(client); c.getOutInterceptors().add(new LoggingOutInterceptor()); c.getInInterceptors().add(new LoggingInInterceptor()); assertEquals("hello",client.sayHello()); assertEquals("hello",client.echo("hello")); }

Class: org.apache.cxf.service.factory.ServerFactoryTest

InternalCallVerifier EqualityVerifier 
@Test public void testJaxbExtraClass() throws Exception { ServerFactoryBean svrBean=new ServerFactoryBean(); svrBean.setAddress("http://localhost/Hello"); svrBean.setServiceClass(HelloServiceImpl.class); svrBean.setBus(getBus()); Map props=svrBean.getProperties(); if (props == null) { props=new HashMap(); } props.put("jaxb.additionalContextClasses",new Class[]{GreetMe.class,GreetMeOneWay.class}); svrBean.setProperties(props); Server serv=svrBean.create(); Class[] extraClass=((JAXBDataBinding)serv.getEndpoint().getService().getDataBinding()).getExtraClass(); assertEquals(extraClass.length,2); assertEquals(extraClass[0],GreetMe.class); assertEquals(extraClass[1],GreetMeOneWay.class); }

Class: org.apache.cxf.service.model.BindingFaultInfoTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBindingFaultInfo(){ assertNotNull(bindingFaultInfo.getFaultInfo()); assertNull(bindingFaultInfo.getBindingOperation()); assertEquals(bindingFaultInfo.getFaultInfo().getFaultName(),new QName("http://faultns/","fault")); assertEquals(bindingFaultInfo.getFaultInfo().getName().getLocalPart(),"faultMessage"); assertEquals(bindingFaultInfo.getFaultInfo().getName().getNamespaceURI(),"http://apache.org/hello_world_soap_http"); }

Class: org.apache.cxf.service.model.BindingMessageInfoTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testMessage(){ assertNotNull(bindingMessageInfo.getMessageInfo()); assertEquals(bindingMessageInfo.getMessageInfo().getName().getLocalPart(),"testMessage"); assertEquals(bindingMessageInfo.getMessageInfo().getName().getNamespaceURI(),"http://apache.org/hello_world_soap_http"); assertNull(bindingMessageInfo.getBindingOperation()); }

Class: org.apache.cxf.service.model.BindingOperationInfoTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testInputMessage() throws Exception { BindingMessageInfo inputMessage=bindingOperationInfo.getInput(); assertNotNull(inputMessage); assertEquals(inputMessage.getMessageInfo().getName().getLocalPart(),"testInputMessage"); assertEquals(inputMessage.getMessageInfo().getName().getNamespaceURI(),"http://apache.org/hello_world_soap_http"); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testOutputMessage() throws Exception { BindingMessageInfo outputMessage=bindingOperationInfo.getOutput(); assertNotNull(outputMessage); assertEquals(outputMessage.getMessageInfo().getName().getLocalPart(),"testOutputMessage"); assertEquals(outputMessage.getMessageInfo().getName().getNamespaceURI(),"http://apache.org/hello_world_soap_http"); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testOperation() throws Exception { assertEquals(bindingOperationInfo.getOperationInfo().getName(),new QName(TEST_NS,"operationTest")); assertTrue(bindingOperationInfo.getOperationInfo().hasInput()); assertTrue(bindingOperationInfo.getOperationInfo().hasOutput()); assertEquals(bindingOperationInfo.getOperationInfo().getInputName(),"input"); assertEquals(bindingOperationInfo.getOperationInfo().getOutputName(),"output"); assertEquals(bindingOperationInfo.getFaults().iterator().next().getFaultInfo().getFaultName(),new QName(TEST_NS,"fault")); assertEquals(1,bindingOperationInfo.getFaults().size()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testFaultMessage() throws Exception { BindingFaultInfo faultMessage=bindingOperationInfo.getFaults().iterator().next(); assertNotNull(faultMessage); assertEquals(faultMessage.getFaultInfo().getName().getLocalPart(),"faultMessage"); assertEquals(faultMessage.getFaultInfo().getName().getNamespaceURI(),"http://apache.org/hello_world_soap_http"); }

EqualityVerifier 
@Test public void testName() throws Exception { assertEquals(bindingOperationInfo.getName(),new QName(TEST_NS,"operationTest")); }

Class: org.apache.cxf.service.model.FaultInfoTest

InternalCallVerifier EqualityVerifier 
@Test public void testName() throws Exception { assertEquals(faultInfo.getFaultName(),new QName("urn:test:ns","fault")); assertEquals(faultInfo.getName().getLocalPart(),"faultMessage"); assertEquals(faultInfo.getName().getNamespaceURI(),"http://apache.org/hello_world_soap_http"); faultInfo.setFaultName(new QName("urn:test:ns","fault")); assertEquals(faultInfo.getFaultName(),new QName("urn:test:ns","fault")); }

Class: org.apache.cxf.service.model.InterfaceInfoTest

BranchVerifier UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testOperation() throws Exception { QName name=new QName("urn:test:ns","sayHi"); interfaceInfo.addOperation(name); assertEquals("sayHi",interfaceInfo.getOperation(name).getName().getLocalPart()); interfaceInfo.addOperation(new QName("urn:test:ns","greetMe")); assertEquals(interfaceInfo.getOperations().size(),2); boolean duplicatedOperationName=false; try { interfaceInfo.addOperation(name); } catch ( IllegalArgumentException e) { assertEquals(e.getMessage(),"An operation with name [{urn:test:ns}sayHi] already exists in this service"); duplicatedOperationName=true; } if (!duplicatedOperationName) { fail("should get IllegalArgumentException"); } boolean isNull=false; try { QName qname=null; interfaceInfo.addOperation(qname); } catch ( NullPointerException e) { isNull=true; assertEquals(e.getMessage(),"Operation Name cannot be null."); } if (!isNull) { fail("should get NullPointerException"); } }

InternalCallVerifier EqualityVerifier 
@Test public void testName() throws Exception { assertEquals(interfaceInfo.getName().getLocalPart(),"interfaceTest"); assertEquals(interfaceInfo.getName().getNamespaceURI(),"http://apache.org/hello_world_soap_http"); QName qname=new QName("http://apache.org/hello_world_soap_http1","interfaceTest1"); interfaceInfo.setName(qname); assertEquals(interfaceInfo.getName().getLocalPart(),"interfaceTest1"); assertEquals(interfaceInfo.getName().getNamespaceURI(),"http://apache.org/hello_world_soap_http1"); }

Class: org.apache.cxf.service.model.MessageInfoTest

InternalCallVerifier EqualityVerifier 
@Test public void testName() throws Exception { assertEquals(messageInfo.getName().getLocalPart(),"testMessage"); assertEquals(messageInfo.getName().getNamespaceURI(),"http://apache.org/hello_world_soap_http"); }

InternalCallVerifier EqualityVerifier 
@Test public void testMessagePartInfo() throws Exception { QName qname=new QName("http://apache.org/hello_world_soap_http","testMessagePart"); messageInfo.addMessagePart(qname); assertEquals(messageInfo.getMessageParts().size(),1); MessagePartInfo messagePartInfo=messageInfo.getMessagePart(qname); int indexAssigned=messagePartInfo.getIndex(); assertEquals(messagePartInfo.getName().getLocalPart(),"testMessagePart"); assertEquals(messagePartInfo.getName().getNamespaceURI(),"http://apache.org/hello_world_soap_http"); assertEquals(messagePartInfo.getMessageInfo(),messageInfo); messagePartInfo=new MessagePartInfo(new QName("http://apache.org/hello_world_soap_http","testMessagePart"),messageInfo); messageInfo.addMessagePart(messagePartInfo); assertEquals(messageInfo.getMessageParts().size(),1); assertEquals(indexAssigned,messagePartInfo.getIndex()); messagePartInfo=new MessagePartInfo(new QName("http://apache.org/hello_world_soap_http","testMessagePart2"),messageInfo); messageInfo.addMessagePart(messagePartInfo); assertEquals(messageInfo.getMessageParts().size(),2); }

Class: org.apache.cxf.service.model.MessagePartInfoTest

InternalCallVerifier EqualityVerifier 
@Test public void testName() throws Exception { assertEquals(messagePartInfo.getName().getLocalPart(),"testMessagePart"); assertEquals(messagePartInfo.getName().getNamespaceURI(),"http://apache.org/hello_world_soap_http"); messagePartInfo.setName(new QName("http://apache.org/hello_world_soap_http1","testMessagePart1")); assertEquals(messagePartInfo.getName().getLocalPart(),"testMessagePart1"); assertEquals(messagePartInfo.getName().getNamespaceURI(),"http://apache.org/hello_world_soap_http1"); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testElement(){ messagePartInfo.setElementQName(new QName("http://apache.org/hello_world_soap_http/types","testElement")); assertTrue(messagePartInfo.isElement()); assertEquals(messagePartInfo.getElementQName().getLocalPart(),"testElement"); assertEquals(messagePartInfo.getElementQName().getNamespaceURI(),"http://apache.org/hello_world_soap_http/types"); assertNull(messagePartInfo.getTypeQName()); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testType(){ messagePartInfo.setTypeQName(new QName("http://apache.org/hello_world_soap_http/types","testType")); assertNull(messagePartInfo.getElementQName()); assertFalse(messagePartInfo.isElement()); assertEquals(messagePartInfo.getTypeQName().getLocalPart(),"testType"); assertEquals(messagePartInfo.getTypeQName().getNamespaceURI(),"http://apache.org/hello_world_soap_http/types"); }

Class: org.apache.cxf.service.model.OperationInfoTest

UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testFault() throws Exception { assertEquals(operationInfo.getFaults().size(),0); QName faultName=new QName("urn:test:ns","fault"); operationInfo.addFault(faultName,new QName("http://apache.org/hello_world_soap_http","faultMessage")); assertEquals(operationInfo.getFaults().size(),1); FaultInfo fault=operationInfo.getFault(faultName); assertNotNull(fault); assertEquals(fault.getFaultName().getLocalPart(),"fault"); assertEquals(fault.getName().getLocalPart(),"faultMessage"); assertEquals(fault.getName().getNamespaceURI(),"http://apache.org/hello_world_soap_http"); operationInfo.removeFault(faultName); assertEquals(operationInfo.getFaults().size(),0); try { operationInfo.addFault(null,null); fail("should get NullPointerException"); } catch ( NullPointerException e) { assertEquals("Fault Name cannot be null.",e.getMessage()); } try { operationInfo.addFault(faultName,null); operationInfo.addFault(faultName,null); fail("should get IllegalArgumentException"); } catch ( IllegalArgumentException e) { assertEquals(e.getMessage(),"A fault with name [{urn:test:ns}fault] already exists in this operation"); } }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testOutput() throws Exception { assertFalse(operationInfo.hasOutput()); MessageInfo outputMessage=operationInfo.createMessage(new QName("http://apache.org/hello_world_soap_http","testOutputMessage"),MessageInfo.Type.OUTPUT); operationInfo.setOutput("output",outputMessage); assertTrue(operationInfo.hasOutput()); outputMessage=operationInfo.getOutput(); assertEquals("testOutputMessage",outputMessage.getName().getLocalPart()); assertEquals("http://apache.org/hello_world_soap_http",outputMessage.getName().getNamespaceURI()); assertEquals(operationInfo.getOutputName(),"output"); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testInput() throws Exception { assertFalse(operationInfo.hasInput()); MessageInfo inputMessage=operationInfo.createMessage(new QName("http://apache.org/hello_world_soap_http","testInputMessage"),MessageInfo.Type.INPUT); operationInfo.setInput("input",inputMessage); assertTrue(operationInfo.hasInput()); inputMessage=operationInfo.getInput(); assertEquals("testInputMessage",inputMessage.getName().getLocalPart()); assertEquals("http://apache.org/hello_world_soap_http",inputMessage.getName().getNamespaceURI()); assertEquals(operationInfo.getInputName(),"input"); }

UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testName() throws Exception { assertNull(operationInfo.getInterface()); assertEquals("operationTest",operationInfo.getName().getLocalPart()); operationInfo.setName(new QName("urn:test:ns","operationTest2")); assertEquals("operationTest2",operationInfo.getName().getLocalPart()); try { operationInfo.setName(null); fail("should catch IllegalArgumentException since name is null"); } catch ( NullPointerException e) { assertEquals(e.getMessage(),"Operation Name cannot be null."); } }

Class: org.apache.cxf.staxutils.DepthXMLStreamReaderTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testReader() throws Exception { XMLStreamReader reader=StaxUtils.createXMLStreamReader(getClass().getResourceAsStream("./resources/amazon.xml")); DepthXMLStreamReader dr=new DepthXMLStreamReader(reader); StaxUtils.toNextElement(dr); assertEquals("ItemLookup",dr.getLocalName()); assertEquals(XMLStreamReader.START_ELEMENT,reader.getEventType()); assertEquals(1,dr.getDepth()); assertEquals(0,dr.getAttributeCount()); dr.next(); assertEquals(1,dr.getDepth()); assertTrue(dr.isWhiteSpace()); dr.nextTag(); assertEquals(2,dr.getDepth()); assertEquals("SubscriptionId",dr.getLocalName()); dr.next(); assertEquals("1E5AY4ZG53H4AMC8QH82",dr.getText()); dr.close(); }

Class: org.apache.cxf.staxutils.FragmentStreamReaderTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testReader() throws Exception { XMLStreamReader reader=StaxUtils.createXMLStreamReader(getClass().getResourceAsStream("./resources/amazon.xml")); DepthXMLStreamReader dr=new DepthXMLStreamReader(reader); StaxUtils.toNextElement(dr); assertEquals("ItemLookup",dr.getLocalName()); assertEquals(XMLStreamReader.START_ELEMENT,reader.getEventType()); FragmentStreamReader fsr=new FragmentStreamReader(dr); assertTrue(fsr.hasNext()); assertEquals(XMLStreamReader.START_DOCUMENT,fsr.getEventType()); fsr.next(); assertEquals("ItemLookup",fsr.getLocalName()); assertEquals("ItemLookup",dr.getLocalName()); assertEquals(XMLStreamReader.START_ELEMENT,reader.getEventType()); fsr.close(); }

Class: org.apache.cxf.staxutils.PropertiesExpandingStreamReaderTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testSystemPropertyExpansion() throws Exception { Map map=new HashMap(); map.put("bar","BAR-VALUE"); map.put("blah","BLAH-VALUE"); XMLStreamReader reader=new PropertiesExpandingStreamReader(StaxUtils.createXMLStreamReader(getTestStream("./resources/sysprops.xml")),map); Document doc=StaxUtils.read(reader); Element abc=DOMUtils.getChildrenWithName(doc.getDocumentElement(),"http://foo/bar","abc").iterator().next(); assertEquals("fooBAR-VALUEfoo",abc.getTextContent()); Element def=DOMUtils.getChildrenWithName(doc.getDocumentElement(),"http://foo/bar","def").iterator().next(); assertEquals("ggggg",def.getTextContent()); assertEquals("BLAH-VALUE2",def.getAttribute("myAttr")); }

Class: org.apache.cxf.staxutils.StaxStreamFilterTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testFilterRPC() throws Exception { StaxStreamFilter filter=new StaxStreamFilter(new QName[]{SOAP_ENV,SOAP_BODY}); String soapMessage="./resources/greetMeRpcLitReq.xml"; XMLStreamReader reader=StaxUtils.createXMLStreamReader(getTestStream(soapMessage)); reader=StaxUtils.createFilteredReader(reader,filter); DepthXMLStreamReader dr=new DepthXMLStreamReader(reader); StaxUtils.toNextElement(dr); assertEquals(new QName("http://apache.org/hello_world_rpclit","sendReceiveData"),dr.getName()); StaxUtils.nextEvent(dr); StaxUtils.toNextElement(dr); assertEquals(new QName("","in"),dr.getName()); StaxUtils.nextEvent(dr); StaxUtils.toNextElement(dr); assertEquals(new QName("http://apache.org/hello_world_rpclit/types","elem1"),dr.getName()); StaxUtils.nextEvent(dr); StaxUtils.toNextText(dr); assertEquals("this is element 1",dr.getText()); StaxUtils.toNextElement(dr); assertEquals(new QName("http://apache.org/hello_world_rpclit/types","elem1"),dr.getName()); assertEquals(XMLStreamConstants.END_ELEMENT,dr.getEventType()); StaxUtils.nextEvent(dr); StaxUtils.toNextElement(dr); assertEquals(new QName("http://apache.org/hello_world_rpclit/types","elem2"),dr.getName()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testFilter() throws Exception { StaxStreamFilter filter=new StaxStreamFilter(new QName[]{SOAP_ENV,SOAP_BODY}); String soapMessage="./resources/sayHiRpcLiteralReq.xml"; XMLStreamReader reader=StaxUtils.createXMLStreamReader(getTestStream(soapMessage)); reader=StaxUtils.createFilteredReader(reader,filter); DepthXMLStreamReader dr=new DepthXMLStreamReader(reader); StaxUtils.toNextElement(dr); QName sayHi=new QName("http://apache.org/hello_world_rpclit","sayHi"); assertEquals(sayHi,dr.getName()); }

Class: org.apache.cxf.staxutils.StaxUtilsTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testToNextTag() throws Exception { String soapMessage="./resources/headerSoapReq.xml"; XMLStreamReader r=StaxUtils.createXMLStreamReader(getTestStream(soapMessage)); DepthXMLStreamReader reader=new DepthXMLStreamReader(r); reader.nextTag(); StaxUtils.toNextTag(reader,new QName("http://schemas.xmlsoap.org/soap/envelope/","Body")); assertEquals("Body",reader.getLocalName()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testCXF3193() throws Exception { String testString=""; CachingXmlEventWriter writer=new CachingXmlEventWriter(); StaxUtils.copy(StaxUtils.createXMLStreamReader(new StringReader(testString)),writer); StringWriter swriter=new StringWriter(); XMLStreamWriter xwriter=StaxUtils.createXMLStreamWriter(swriter); for ( XMLEvent event : writer.getEvents()) { StaxUtils.writeEvent(event,xwriter); } xwriter.flush(); String s=swriter.toString(); int idx=s.indexOf("xmlns:a"); idx=s.indexOf("xmlns:a",idx + 1); assertEquals(-1,idx); }

APIUtilityVerifier UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testQName() throws Exception { StringBuilder in=new StringBuilder(); in.append(""); in.append("f:Bar"); in.append(" f:Bar "); in.append("x:Bar"); in.append(""); XMLStreamReader reader=StaxUtils.createXMLStreamReader(new ByteArrayInputStream(in.toString().getBytes())); QName qname=new QName("http://example.com/","Bar"); assertEquals(XMLStreamReader.START_ELEMENT,reader.next()); assertEquals(XMLStreamReader.START_ELEMENT,reader.next()); assertEquals(qname,StaxUtils.readQName(reader)); assertEquals(XMLStreamReader.START_ELEMENT,reader.next()); assertEquals(qname,StaxUtils.readQName(reader)); assertEquals(XMLStreamReader.START_ELEMENT,reader.next()); try { StaxUtils.readQName(reader); fail("invalid qname in mapping"); } catch ( Exception e) { } }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testToNextElement(){ String soapMessage="./resources/sayHiRpcLiteralReq.xml"; XMLStreamReader r=StaxUtils.createXMLStreamReader(getTestStream(soapMessage)); DepthXMLStreamReader reader=new DepthXMLStreamReader(r); assertTrue(StaxUtils.toNextElement(reader)); assertEquals("Envelope",reader.getLocalName()); StaxUtils.nextEvent(reader); assertTrue(StaxUtils.toNextElement(reader)); assertEquals("Body",reader.getLocalName()); }

EqualityVerifier 
@Test public void testCopyFromTheMiddle() throws Exception { String innerXml="\n" + "body text here\n" + "\n"; String xml="\n" + innerXml + ""; StringReader reader=new StringReader(xml); DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); dbf.setValidating(false); Document doc=dbf.newDocumentBuilder().parse(new InputSource(reader)); Source source=new DOMSource(doc); XMLStreamReader sreader=StaxUtils.createXMLStreamReader(source); while (!"inner".equals(sreader.getLocalName())) { sreader.next(); } StringWriter sw=new StringWriter(); XMLStreamWriter swriter=StaxUtils.createXMLStreamWriter(sw); StaxUtils.copy(sreader,swriter,true,true); swriter.flush(); swriter.close(); assertEquals(innerXml,sw.toString()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testCopy() throws Exception { String soapMessage="./resources/headerSoapReq.xml"; ByteArrayOutputStream baos=new ByteArrayOutputStream(); XMLStreamReader reader=StaxUtils.createXMLStreamReader(getTestStream(soapMessage)); XMLStreamWriter writer=StaxUtils.createXMLStreamWriter(baos); StaxUtils.copy(reader,writer); writer.flush(); baos.flush(); String output=baos.toString(); InputStreamReader inputStreamReader=new InputStreamReader(getTestStream(soapMessage)); StringWriter stringWriter=new StringWriter(); char[] buffer=new char[4096]; int n=0; n=inputStreamReader.read(buffer); while (n > 0) { stringWriter.write(buffer,0,n); n=inputStreamReader.read(buffer); } String input=stringWriter.toString(); int beginIndex=input.indexOf("

EqualityVerifier 
@Test public void testCopyWithEmptyNamespace() throws Exception { StringBuilder in=new StringBuilder(); in.append(""); in.append(""); in.append(""); XMLStreamReader reader=StaxUtils.createXMLStreamReader(new ByteArrayInputStream(in.toString().getBytes())); Writer out=new StringWriter(); XMLStreamWriter writer=StaxUtils.createXMLStreamWriter(out); StaxUtils.copy(reader,writer); writer.close(); assertEquals(in.toString(),out.toString()); }

Class: org.apache.cxf.staxutils.W3CDOMStreamReaderTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testTopLevelText() throws Exception { ByteArrayInputStream is=new ByteArrayInputStream("gorilla".getBytes("utf-8")); Document doc=StaxUtils.read(is); Element e=doc.getDocumentElement(); XMLStreamReader reader=StaxUtils.createXMLStreamReader(e); String value=reader.getElementText(); assertEquals("gorilla",value); }

Class: org.apache.cxf.staxutils.transform.DelegatingNamespaceContextTest

UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSomeAddsAndGets() throws Exception { DelegatingNamespaceContext dnc=getTestDelegatingNamespaceContext(); dnc.down(); dnc.addPrefix("p1","urn:foo1"); dnc.addPrefix("p2","urn:foo2"); assertEquals("urn:foo0",dnc.getNamespaceURI("p0")); assertEquals("urn:foo1",dnc.getNamespaceURI("p1")); assertEquals("urn:foo2",dnc.getNamespaceURI("p2")); assertEquals("p0",dnc.getPrefix("urn:foo0")); assertEquals("p1",dnc.getPrefix("urn:foo1")); assertEquals("p2",dnc.getPrefix("urn:foo2")); verifyPrefixes(dnc.getPrefixes("urn:foo1"),new String[]{"p1"}); verifyPrefixes(dnc.getPrefixes("urn:foo2"),new String[]{"p2"}); dnc.down(); dnc.addPrefix("p11","urn:foo1"); dnc.addPrefix("p2","urn:foo22"); dnc.addPrefix("p3","urn:foo3"); assertEquals("urn:foo1",dnc.getNamespaceURI("p1")); assertEquals("urn:foo1",dnc.getNamespaceURI("p11")); assertEquals("urn:foo22",dnc.getNamespaceURI("p2")); assertEquals("urn:foo3",dnc.getNamespaceURI("p3")); String p=dnc.getPrefix("urn:foo1"); assertTrue("p1".equals(p) || "p11".equals(p)); assertNull(dnc.getPrefix("urn:foo2")); assertEquals("p2",dnc.getPrefix("urn:foo22")); assertEquals("p3",dnc.getPrefix("urn:foo3")); p=dnc.findUniquePrefix("urn:foo4"); assertNotNull(p); assertEquals(p,dnc.getPrefix("urn:foo4")); assertEquals("urn:foo4",dnc.getNamespaceURI(p)); verifyPrefixes(dnc.getPrefixes("urn:foo1"),new String[]{"p1","p11"}); verifyPrefixes(dnc.getPrefixes("urn:foo2"),new String[]{}); verifyPrefixes(dnc.getPrefixes("urn:foo22"),new String[]{"p2"}); verifyPrefixes(dnc.getPrefixes("urn:foo3"),new String[]{"p3"}); dnc.up(); assertEquals("urn:foo1",dnc.getNamespaceURI("p1")); assertNull(dnc.getNamespaceURI("p11")); assertEquals("urn:foo2",dnc.getNamespaceURI("p2")); assertNull(dnc.getNamespaceURI("p3")); assertEquals("p1",dnc.getPrefix("urn:foo1")); assertNull(dnc.getPrefix("urn:foo11")); assertEquals("p2",dnc.getPrefix("urn:foo2")); assertNull(dnc.getPrefix("urn:foo22")); assertNull(dnc.getPrefix("urn:foo3")); verifyPrefixes(dnc.getPrefixes("urn:foo1"),new String[]{"p1"}); verifyPrefixes(dnc.getPrefixes("urn:foo2"),new String[]{"p2"}); verifyPrefixes(dnc.getPrefixes("urn:foo3"),new String[]{}); dnc.up(); try { dnc.up(); fail("not allowed to go up"); } catch ( Exception e) { } }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testSomeAddsWithDuplicatedPrefixName() throws Exception { DelegatingNamespaceContext dnc=getTestDelegatingNamespaceContext(); dnc.down(); dnc.addPrefix("p00","urn:foo0"); dnc.addPrefix("p1","urn:foo1"); dnc.addPrefix("p2","urn:foo2"); assertEquals("urn:foo0",dnc.getNamespaceURI("p0")); assertEquals("urn:foo0",dnc.getNamespaceURI("p00")); assertEquals("urn:foo1",dnc.getNamespaceURI("p1")); assertEquals("urn:foo2",dnc.getNamespaceURI("p2")); assertTrue("p0".equals(dnc.getPrefix("urn:foo0")) || "p00".equals(dnc.getPrefix("urn:foo0"))); assertEquals("p1",dnc.getPrefix("urn:foo1")); assertEquals("p2",dnc.getPrefix("urn:foo2")); verifyPrefixes(dnc.getPrefixes("urn:foo1"),new String[]{"p1"}); verifyPrefixes(dnc.getPrefixes("urn:foo2"),new String[]{"p2"}); verifyPrefixes(dnc.getPrefixes("urn:foo0"),new String[]{"p0","p00"}); }

Class: org.apache.cxf.staxutils.transform.InTransformReaderTest

APIUtilityVerifier EqualityVerifier 
@Test public void testReplaceSimpleElement() throws Exception { InputStream is=new ByteArrayInputStream("1".getBytes()); XMLStreamReader reader=StaxUtils.createXMLStreamReader(is); reader=new InTransformReader(reader,null,Collections.singletonMap("{http://bar}a","{http://bar}a=1 2 3"),null,null,false); ByteArrayOutputStream bos=new ByteArrayOutputStream(); StaxUtils.copy(reader,bos); String value=bos.toString(); assertEquals("1 2 3",value); }

APIUtilityVerifier EqualityVerifier 
@Test public void testReadWithParentDefaultNamespace() throws Exception { InputStream is=new ByteArrayInputStream("".getBytes()); XMLStreamReader reader=StaxUtils.createXMLStreamReader(is); reader=new InTransformReader(reader,Collections.singletonMap("{http://bar1}subtest","subtest"),null,null,null,false); ByteArrayOutputStream bos=new ByteArrayOutputStream(); StaxUtils.copy(reader,bos); String value=bos.toString(); assertEquals("",value); }

APIUtilityVerifier EqualityVerifier 
@Test public void testTransformAndReplaceSimpleElement() throws Exception { InputStream is=new ByteArrayInputStream("1".getBytes()); XMLStreamReader reader=StaxUtils.createXMLStreamReader(is); reader=new InTransformReader(reader,Collections.singletonMap("{http://bar}*","{http://foo}*"),Collections.singletonMap("{http://bar}a","{http://bar}a=1 2 3"),null,null,false); ByteArrayOutputStream bos=new ByteArrayOutputStream(); StaxUtils.copy(reader,bos); String value=bos.toString(); assertEquals("1 2 3",value); }

Class: org.apache.cxf.staxutils.transform.OutTransformWriterTest

APIUtilityVerifier EqualityVerifier 
@Test public void testReplaceSimpleElement() throws Exception { InputStream is=new ByteArrayInputStream("1".getBytes()); ByteArrayOutputStream os=new ByteArrayOutputStream(); XMLStreamWriter writer=new OutTransformWriter(StaxUtils.createXMLStreamWriter(os,StandardCharsets.UTF_8.name()),null,Collections.singletonMap("{http://bar}a","{http://bar}a=1 2 3"),null,null,false,null); StaxUtils.copy(new StreamSource(is),writer); writer.flush(); XMLStreamReader reader=StaxUtils.createXMLStreamReader(new ByteArrayInputStream(os.toByteArray())); ByteArrayOutputStream bos=new ByteArrayOutputStream(); StaxUtils.copy(reader,bos); String value=bos.toString(); assertEquals("1 2 3",value); }

APIUtilityVerifier EqualityVerifier 
@Test public void testReplaceDefaultNamespace() throws Exception { InputStream is=new ByteArrayInputStream("1".getBytes()); ByteArrayOutputStream os=new ByteArrayOutputStream(); XMLStreamWriter writer=new OutTransformWriter(StaxUtils.createXMLStreamWriter(os,StandardCharsets.UTF_8.name()),null,null,null,null,false,""); StaxUtils.copy(new StreamSource(is),writer); writer.flush(); XMLStreamReader reader=StaxUtils.createXMLStreamReader(new ByteArrayInputStream(os.toByteArray())); ByteArrayOutputStream bos=new ByteArrayOutputStream(); StaxUtils.copy(reader,bos); String value=bos.toString(); assertEquals("1",value); }

EqualityVerifier 
@Test public void testDefaultNamespace() throws Exception { ByteArrayOutputStream os=new ByteArrayOutputStream(); XMLStreamWriter writer=StaxUtils.createXMLStreamWriter(os,StandardCharsets.UTF_8.name()); Map outMap=new HashMap(); outMap.put("{http://testbeans.com}*","{http://testbeans.com/v2}*"); OutTransformWriter transformWriter=new OutTransformWriter(writer,outMap,Collections.emptyMap(),Collections.emptyList(),false,"http://testbeans.com/v2"); JAXBContext context=JAXBContext.newInstance(TestBean.class); Marshaller m=context.createMarshaller(); m.marshal(new TestBean(),transformWriter); String expected="" + ""; assertEquals(expected,os.toString()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testNamespaceConversion() throws Exception { W3CDOMStreamWriter writer=new W3CDOMStreamWriter(); JAXBContext context=JAXBContext.newInstance(TestBean.class); Marshaller m=context.createMarshaller(); Map outMap=new HashMap(); outMap.put("{http://testbeans.com}testBean","{http://testbeans.com/v2}testBean"); outMap.put("{http://testbeans.com}bean","{http://testbeans.com/v3}bean"); OutTransformWriter transformWriter=new OutTransformWriter(writer,outMap,Collections.emptyMap(),Collections.emptyList(),false,""); m.marshal(new TestBean(),transformWriter); Element el=writer.getDocument().getDocumentElement(); assertEquals("http://testbeans.com/v2",el.getNamespaceURI()); assertFalse(StringUtils.isEmpty(el.getPrefix())); Element el2=DOMUtils.getFirstElement(el); assertEquals("http://testbeans.com/v3",el2.getNamespaceURI()); assertFalse(StringUtils.isEmpty(el2.getPrefix())); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testNamespaceConversionAndDefaultNS() throws Exception { W3CDOMStreamWriter writer=new W3CDOMStreamWriter(); Map outMap=new HashMap(); outMap.put("{http://testbeans.com}testBean","{http://testbeans.com/v2}testBean"); outMap.put("{http://testbeans.com}bean","{http://testbeans.com/v3}bean"); OutTransformWriter transformWriter=new OutTransformWriter(writer,outMap,Collections.emptyMap(),Collections.emptyList(),false,"http://testbeans.com/v2"); JAXBContext context=JAXBContext.newInstance(TestBean.class); Marshaller m=context.createMarshaller(); m.marshal(new TestBean(),transformWriter); Element el=writer.getDocument().getDocumentElement(); assertEquals("http://testbeans.com/v2",el.getNamespaceURI()); assertTrue(StringUtils.isEmpty(el.getPrefix())); el=DOMUtils.getFirstElement(el); assertEquals("http://testbeans.com/v3",el.getNamespaceURI()); assertFalse(StringUtils.isEmpty(el.getPrefix())); }

Class: org.apache.cxf.sts.claims.mapper.JexlClaimsMapperTest

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testRoleMappings() throws IOException { ProcessedClaimCollection result=jcm.mapClaims("A",createClaimCollection(),"B",createProperties()); assertNotNull(result); assertTrue(result.size() >= 1); assertEquals(2,result.get(0).getValues().size()); assertTrue(result.get(0).getValues().contains("manager")); assertTrue(result.get(0).getValues().contains("administrator")); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSingleToMultiValue() throws IOException { ProcessedClaimCollection result=jcm.mapClaims("A",createClaimCollection(),"B",createProperties()); assertNotNull(result); ProcessedClaim claim=findClaim(result,"http://my.schema.org/identity/claims/single2multi"); assertNotNull(claim); assertNotNull(claim.getValues()); assertEquals(3,claim.getValues().size()); assertEquals("Value2",claim.getValues().get(1)); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testMultiToSingleValue() throws IOException { ProcessedClaimCollection result=jcm.mapClaims("A",createClaimCollection(),"B",createProperties()); assertNotNull(result); ProcessedClaim claim=findClaim(result,"http://my.schema.org/identity/claims/multi2single"); assertNotNull(claim); assertNotNull(claim.getValues()); assertEquals(1,claim.getValues().size()); assertEquals("Value1,Value2,Value3",claim.getValues().get(0)); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testValueFilter() throws IOException { ProcessedClaimCollection result=jcm.mapClaims("A",createClaimCollection(),"B",createProperties()); assertNotNull(result); ProcessedClaim claim=findClaim(result,"http://my.schema.org/identity/claims/filter"); assertEquals(2,claim.getValues().size()); assertTrue(claim.getValues().contains("match")); assertTrue(claim.getValues().contains("second_match")); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSimpleClaimCopy() throws IOException { ProcessedClaimCollection result=jcm.mapClaims("A",createClaimCollection(),"B",createProperties()); assertNotNull(result); ProcessedClaim claim=findClaim(result,"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/mail"); assertNotNull(claim); assertNotNull(claim.getValues()); assertEquals(1,claim.getValues().size()); assertEquals("test@apache.com",claim.getValues().get(0)); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testWrappedUpperCaseClaim() throws IOException { ProcessedClaimCollection result=jcm.mapClaims("A",createClaimCollection(),"B",createProperties()); assertNotNull(result); ProcessedClaim claim=findClaim(result,"http://my.schema.org/identity/claims/wrappedUppercase"); assertNotNull(claim); assertNotNull(claim.getValues()); assertEquals(1,claim.getValues().size()); assertEquals("PREFIX_VALUE_SUFFIX",claim.getValues().get(0)); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testUpdateIssuer() throws IOException { ProcessedClaimCollection result=jcm.mapClaims("A",createClaimCollection(),"B",createProperties()); assertNotNull(result); assertEquals("STS-B",result.get(0).getOriginalIssuer()); assertEquals("NewIssuer",result.get(0).getIssuer()); assertEquals("STS-A",result.get(1).getOriginalIssuer()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testLowerCaseClaim() throws IOException { ProcessedClaimCollection result=jcm.mapClaims("A",createClaimCollection(),"B",createProperties()); assertNotNull(result); ProcessedClaim claim=findClaim(result,"http://my.schema.org/identity/claims/lowercase"); assertNotNull(claim); assertNotNull(claim.getValues()); assertEquals(2,claim.getValues().size()); assertEquals("value2",claim.getValues().get(1)); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testUpperCaseClaim() throws IOException { ProcessedClaimCollection result=jcm.mapClaims("A",createClaimCollection(),"B",createProperties()); assertNotNull(result); ProcessedClaim claim=findClaim(result,"http://my.schema.org/identity/claims/uppercase"); assertNotNull(claim); assertNotNull(claim.getValues()); assertEquals(2,claim.getValues().size()); assertEquals("VALUE2",claim.getValues().get(1)); }

BranchVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testClaimMerge() throws IOException { ProcessedClaimCollection result=jcm.mapClaims("A",createClaimCollection(),"B",createProperties()); assertNotNull(result); assertTrue(result.size() >= 2); assertEquals("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name",result.get(1).getClaimType().toString()); assertEquals(1,result.get(1).getValues().size()); assertEquals("Jan Bernhardt",result.get(1).getValues().get(0)); for ( ProcessedClaim c : result) { if ("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname".equals(c.getClaimType())) { fail("Only merged claim should be in result set, but not the individual claims"); } } }

Class: org.apache.cxf.systest.aegis.AegisClientServerTest

InternalCallVerifier EqualityVerifier 
@Test public void testCollection() throws Exception { AegisDatabinding aegisBinding=new AegisDatabinding(); JaxWsProxyFactoryBean proxyFactory=new JaxWsProxyFactoryBean(); proxyFactory.setDataBinding(aegisBinding); proxyFactory.setServiceClass(SportsService.class); proxyFactory.setWsdlLocation("http://localhost:" + PORT + "/jaxwsAndAegisSports?wsdl"); proxyFactory.getInInterceptors().add(new LoggingInInterceptor()); proxyFactory.getOutInterceptors().add(new LoggingOutInterceptor()); SportsService service=(SportsService)proxyFactory.create(); Collection teams=service.getTeams(); assertEquals(1,teams.size()); assertEquals("Patriots",teams.iterator().next().getName()); String s=service.testForMinOccurs0("A",null,"b"); assertEquals("Anullb",s); }

InternalCallVerifier EqualityVerifier 
@Test public void testQualifiedPair() throws Exception { AegisDatabinding aegisBinding=new AegisDatabinding(); JaxWsProxyFactoryBean proxyFactory=new JaxWsProxyFactoryBean(); proxyFactory.setDataBinding(aegisBinding); proxyFactory.setServiceClass(SportsService.class); proxyFactory.setAddress("http://localhost:" + PORT + "/jaxwsAndAegisSports"); proxyFactory.getInInterceptors().add(new LoggingInInterceptor()); proxyFactory.getOutInterceptors().add(new LoggingOutInterceptor()); SportsService service=(SportsService)proxyFactory.create(); int ret=service.getQualifiedPair(new Pair(111,"ffang")); assertEquals(111,ret); }

InternalCallVerifier EqualityVerifier 
@Test public void testGenericCollection() throws Exception { AegisDatabinding aegisBinding=new AegisDatabinding(); JaxWsProxyFactoryBean proxyFactory=new JaxWsProxyFactoryBean(); proxyFactory.setDataBinding(aegisBinding); proxyFactory.setServiceClass(SportsService.class); proxyFactory.setAddress("http://localhost:" + PORT + "/jaxwsAndAegisSports"); proxyFactory.getInInterceptors().add(new LoggingInInterceptor()); proxyFactory.getOutInterceptors().add(new LoggingOutInterceptor()); SportsService service=(SportsService)proxyFactory.create(); List list=new ArrayList(); list.add("ffang"); String ret=service.getGeneric(list); assertEquals(ret,"ffang"); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testDynamicClient() throws Exception { DynamicClientFactory dcf=DynamicClientFactory.newInstance(); Client client=dcf.createClient("http://localhost:" + PORT + "/jaxwsAndAegisSports?wsdl&dynamic"); Object r=client.invoke("getAttributeBean")[0]; Method getAddrPlainString=r.getClass().getMethod("getAttrPlainString"); String s=(String)getAddrPlainString.invoke(r); assertEquals("attrPlain",s); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testComplexMapResult() throws Exception { AegisDatabinding aegisBinding=new AegisDatabinding(); JaxWsProxyFactoryBean proxyFactory=new JaxWsProxyFactoryBean(); proxyFactory.setDataBinding(aegisBinding); proxyFactory.setServiceClass(SportsService.class); proxyFactory.setAddress("http://localhost:" + PORT + "/jaxwsAndAegisSports"); proxyFactory.getInInterceptors().add(new LoggingInInterceptor()); proxyFactory.getOutInterceptors().add(new LoggingOutInterceptor()); SportsService service=(SportsService)proxyFactory.create(); Map> result=service.testComplexMapResult(); assertEquals(result.size(),1); assertTrue(result.containsKey("key1")); assertNotNull(result.get("key1")); assertEquals(result.toString(),"{key1={1=3}}"); }

InternalCallVerifier EqualityVerifier 
@Test public void testReturnGenericPair() throws Exception { AegisDatabinding aegisBinding=new AegisDatabinding(); JaxWsProxyFactoryBean proxyFactory=new JaxWsProxyFactoryBean(); proxyFactory.setDataBinding(aegisBinding); proxyFactory.setServiceClass(SportsService.class); proxyFactory.setAddress("http://localhost:" + PORT + "/jaxwsAndAegisSports"); proxyFactory.getInInterceptors().add(new LoggingInInterceptor()); proxyFactory.getOutInterceptors().add(new LoggingOutInterceptor()); SportsService service=(SportsService)proxyFactory.create(); int ret=service.getGenericPair(new Pair(111,"String")); assertEquals(111,ret); }

InternalCallVerifier EqualityVerifier 
@Test public void testReturnQualifiedPair() throws Exception { AegisDatabinding aegisBinding=new AegisDatabinding(); JaxWsProxyFactoryBean proxyFactory=new JaxWsProxyFactoryBean(); proxyFactory.setDataBinding(aegisBinding); proxyFactory.setServiceClass(SportsService.class); proxyFactory.setAddress("http://localhost:" + PORT + "/jaxwsAndAegisSports"); proxyFactory.getInInterceptors().add(new LoggingInInterceptor()); proxyFactory.getOutInterceptors().add(new LoggingOutInterceptor()); SportsService service=(SportsService)proxyFactory.create(); Pair ret=service.getReturnQualifiedPair(111,"ffang"); assertEquals(new Integer(111),ret.getFirst()); assertEquals("ffang",ret.getSecond()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testAegisClient() throws Exception { AegisDatabinding aegisBinding=new AegisDatabinding(); ClientProxyFactoryBean proxyFactory=new ClientProxyFactoryBean(); proxyFactory.setDataBinding(aegisBinding); proxyFactory.setServiceClass(AuthService.class); proxyFactory.setAddress("http://localhost:" + PORT + "/service"); AuthService service=(AuthService)proxyFactory.create(); assertTrue(service.authenticate("Joe","Joe","123")); assertFalse(service.authenticate("Joe1","Joe","fang")); assertTrue(service.authenticate("Joe",null,"123")); List list=service.getRoles("Joe"); assertEquals(3,list.size()); assertEquals("Joe",list.get(0)); assertEquals("Joe-1",list.get(1)); assertEquals("Joe-2",list.get(2)); String roles[]=service.getRolesAsArray("Joe"); assertEquals(2,roles.length); assertEquals("Joe",roles[0]); assertEquals("Joe-1",roles[1]); assertEquals("get Joe",service.getAuthentication("Joe")); Authenticate au=new Authenticate(); au.setSid("ffang"); au.setUid("ffang"); assertTrue(service.authenticate(au)); au.setUid("ffang1"); assertFalse(service.authenticate(au)); }

InternalCallVerifier EqualityVerifier 
@Test public void testGenericPair() throws Exception { AegisDatabinding aegisBinding=new AegisDatabinding(); JaxWsProxyFactoryBean proxyFactory=new JaxWsProxyFactoryBean(); proxyFactory.setDataBinding(aegisBinding); proxyFactory.setServiceClass(SportsService.class); proxyFactory.setAddress("http://localhost:" + PORT + "/jaxwsAndAegisSports"); proxyFactory.getInInterceptors().add(new LoggingInInterceptor()); proxyFactory.getOutInterceptors().add(new LoggingOutInterceptor()); SportsService service=(SportsService)proxyFactory.create(); Pair ret=service.getReturnGenericPair("ffang",111); assertEquals("ffang",ret.getFirst()); assertEquals(new Integer(111),ret.getSecond()); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testJaxWsAegisClient() throws Exception { AegisDatabinding aegisBinding=new AegisDatabinding(); JaxWsProxyFactoryBean proxyFactory=new JaxWsProxyFactoryBean(); proxyFactory.setDataBinding(aegisBinding); proxyFactory.setServiceClass(AuthService.class); proxyFactory.setAddress("http://localhost:" + PORT + "/jaxwsAndAegis"); AuthService service=(AuthService)proxyFactory.create(); assertTrue(service.authenticate("Joe","Joe","123")); assertFalse(service.authenticate("Joe1","Joe","fang")); assertTrue(service.authenticate("Joe",null,"123")); List list=service.getRoles("Joe"); assertEquals(3,list.size()); assertEquals("Joe",list.get(0)); assertEquals("Joe-1",list.get(1)); assertEquals("Joe-2",list.get(2)); String roles[]=service.getRolesAsArray("Joe"); assertEquals(2,roles.length); assertEquals("Joe",roles[0]); assertEquals("Joe-1",roles[1]); roles=service.getRolesAsArray("null"); assertNull(roles); roles=service.getRolesAsArray("0"); assertEquals(0,roles.length); assertEquals("get Joe",service.getAuthentication("Joe")); Authenticate au=new Authenticate(); au.setSid("ffang"); au.setUid("ffang"); assertTrue(service.authenticate(au)); au.setUid("ffang1"); assertFalse(service.authenticate(au)); }

Class: org.apache.cxf.systest.aegis.AegisJaxWsTest

InternalCallVerifier EqualityVerifier 
@Test public void testGetStringList() throws Exception { setupForTest(false); Integer soucet=client.getSimpleValue(5,"aa"); Assert.assertEquals(new Integer(5),soucet); List item=client.getStringList(); Assert.assertEquals(Arrays.asList("a","b","c"),item); }

InternalCallVerifier EqualityVerifier 
@Test public void testBigList() throws Exception { int size=1000; List l=new ArrayList(size); for (int x=0; x < size; x++) { l.add("Need to create a pretty big soap message to make sure we go over " + "some of the default buffer sizes and such so we can see what really" + "happens when we do that - "+ x); } setupForTest(false); List item=client.echoBigList(l); Assert.assertEquals(size,item.size()); File f=FileUtils.getDefaultTempDir(); Assert.assertEquals(0,f.listFiles().length); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetItem() throws Exception { setupForTest(false); Item item=client.getItemByKey(" a ","b"); Assert.assertEquals(33,item.getKey().intValue()); Assert.assertEquals(" a :b",item.getData()); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetItemSecure() throws Exception { setupForTest(true); Item item=client.getItemByKey(" jack&jill ","b"); Assert.assertEquals(33,item.getKey().intValue()); Assert.assertEquals(" jack&jill :b",item.getData()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testMapSpecified() throws Exception { setupForTest(false); Item item=new Item(); item.setKey(new Integer(42)); item.setData("Godzilla"); client.addItem(item); Map items=client.getItemsMapSpecified(); Assert.assertNotNull(items); Assert.assertEquals(1,items.size()); Map.Entry entry=items.entrySet().iterator().next(); Assert.assertNotNull(entry); Item item2=entry.getValue(); Integer key2=entry.getKey(); Assert.assertEquals(42,key2.intValue()); Assert.assertEquals("Godzilla",item2.getData()); }

Class: org.apache.cxf.systest.aegis.AegisWSDLNSTest

InternalCallVerifier EqualityVerifier 
@Test public void testUsingCorrectMethod() throws Exception { setupForTest(false); Integer result=client.updateInteger(new Integer(20)); Assert.assertEquals(result.intValue(),20); }

Class: org.apache.cxf.systest.aegis.CharacterSchemaTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSchema() throws Exception { testUtilities.setBus((Bus)applicationContext.getBean("cxf")); testUtilities.addDefaultNamespaces(); testUtilities.addNamespace("aegis","http://cxf.apache.org/aegisTypes"); Server s=testUtilities.getServerForService(new QName("http://aegis.systest.cxf.apache.org/","SportsService")); Assert.assertNotNull(s); Document wsdl=testUtilities.getWSDLDocument(s); Assert.assertNotNull(wsdl); NodeList typeAttrList=testUtilities.assertValid("//xsd:complexType[@name='BeanWithCharacter']/xsd:sequence" + "/xsd:element[@name='character']" + "/@type",wsdl); Attr typeAttr=(Attr)typeAttrList.item(0); String typeAttrValue=typeAttr.getValue(); String[] pieces=typeAttrValue.split(":"); Assert.assertEquals(CharacterAsStringType.CHARACTER_AS_STRING_TYPE_QNAME.getLocalPart(),pieces[1]); Node elementNode=typeAttr.getOwnerElement(); String url=testUtilities.resolveNamespacePrefix(pieces[0],elementNode); Assert.assertEquals(CharacterAsStringType.CHARACTER_AS_STRING_TYPE_QNAME.getNamespaceURI(),url); }

Class: org.apache.cxf.systest.aegis.mtom.MtomTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testMtomReply() throws Exception { setupForTest(true); DataHandlerBean dhBean=client.produceDataHandlerBean(); Assert.assertNotNull(dhBean); String result=IOUtils.toString(dhBean.getDataHandler().getInputStream(),"utf-8"); Assert.assertEquals(MtomTestImpl.STRING_DATA,result); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testJaxWsMtomReply() throws Exception { setupForTest(true); DataHandlerBean dhBean=jaxwsClient.produceDataHandlerBean(); Assert.assertNotNull(dhBean); String result=IOUtils.toString(dhBean.getDataHandler().getInputStream(),"utf-8"); Assert.assertEquals(MtomTestImpl.STRING_DATA,result); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAcceptDataHandlerNoMTOM() throws Exception { setupForTest(false); DataHandlerBean dhBean=new DataHandlerBean(); dhBean.setName("some name"); String someData="This is the cereal shot from guns."; DataHandler dataHandler=new DataHandler(someData,"text/plain;charset=utf-8"); dhBean.setDataHandler(dataHandler); client.acceptDataHandler(dhBean); DataHandlerBean accepted=impl.getLastDhBean(); Assert.assertNotNull(accepted); InputStream data=accepted.getDataHandler().getInputStream(); Assert.assertNotNull(data); String dataString=org.apache.commons.io.IOUtils.toString(data,"utf-8"); Assert.assertEquals("This is the cereal shot from guns.",dataString); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAcceptDataHandler() throws Exception { setupForTest(true); DataHandlerBean dhBean=new DataHandlerBean(); dhBean.setName("some name"); String someData="This is the cereal shot from guns."; DataHandler dataHandler=new DataHandler(someData,"text/plain;charset=utf-8"); dhBean.setDataHandler(dataHandler); client.acceptDataHandler(dhBean); DataHandlerBean accepted=impl.getLastDhBean(); Assert.assertNotNull(accepted); Object o=accepted.getDataHandler().getContent(); String data=null; if (o instanceof String) { data=(String)o; } else if (o instanceof InputStream) { data=IOUtils.toString((InputStream)o); } Assert.assertNotNull(data); Assert.assertEquals("This is the cereal shot from guns.",data); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testMtomSchema() throws Exception { testUtilities.setBus((Bus)applicationContext.getBean("cxf")); testUtilities.addDefaultNamespaces(); testUtilities.addNamespace("xmime","http://www.w3.org/2005/05/xmlmime"); Server s=testUtilities.getServerForService(new QName("http://fortest.mtom.aegis.systest.cxf.apache.org/","MtomTestService")); Document wsdl=testUtilities.getWSDLDocument(s); Assert.assertNotNull(wsdl); NodeList typeAttrList=testUtilities.assertValid("//xsd:complexType[@name='inputDhBean']/xsd:sequence/" + "xsd:element[@name='dataHandler']/" + "@type",wsdl); Attr typeAttr=(Attr)typeAttrList.item(0); String typeAttrValue=typeAttr.getValue(); String[] pieces=typeAttrValue.split(":"); Assert.assertEquals("base64Binary",pieces[1]); Node elementNode=typeAttr.getOwnerElement(); String url=testUtilities.resolveNamespacePrefix(pieces[0],elementNode); Assert.assertEquals(Constants.URI_2001_SCHEMA_XSD,url); s=testUtilities.getServerForAddress("http://localhost:" + PORT + "/mtomXmime"); wsdl=testUtilities.getWSDLDocument(s); Assert.assertNotNull(wsdl); typeAttrList=testUtilities.assertValid("//xsd:complexType[@name='inputDhBean']/xsd:sequence/" + "xsd:element[@name='dataHandler']/" + "@type",wsdl); typeAttr=(Attr)typeAttrList.item(0); typeAttrValue=typeAttr.getValue(); pieces=typeAttrValue.split(":"); Assert.assertEquals("base64Binary",pieces[1]); elementNode=typeAttr.getOwnerElement(); url=testUtilities.resolveNamespacePrefix(pieces[0],elementNode); Assert.assertEquals(AbstractXOPType.XML_MIME_NS,url); }

Class: org.apache.cxf.systest.basicDOCBare.DOCBareClientServerTest

IterativeVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBasicConnection() throws Exception { URL wsdl=getClass().getResource("/wsdl/doc_lit_bare.wsdl"); assertNotNull("WSDL is null",wsdl); SOAPService service=new SOAPService(wsdl,serviceName); assertNotNull("Service is null",service); PutLastTradedPricePortType putLastTradedPrice=service.getPort(portName,PutLastTradedPricePortType.class); updateAddressPort(putLastTradedPrice,PORT); String response=putLastTradedPrice.bareNoParam(); assertEquals("testResponse",response); TradePriceData priceData=new TradePriceData(); priceData.setTickerPrice(1.0f); priceData.setTickerSymbol("CELTIX"); Holder holder=new Holder(priceData); for (int i=0; i < 5; i++) { putLastTradedPrice.sayHi(holder); assertEquals(4.5f,holder.value.getTickerPrice(),0.01); assertEquals("APACHE",holder.value.getTickerSymbol()); putLastTradedPrice.putLastTradedPrice(priceData); } }

APIUtilityVerifier BranchVerifier IdentityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAnnotation() throws Exception { Class claz=PutLastTradedPricePortType.class; TradePriceData priceData=new TradePriceData(); Holder holder=new Holder(priceData); Method method=claz.getMethod("sayHi",holder.getClass()); assertNotNull("Can not find SayHi method in generated class ",method); Annotation ann=method.getAnnotation(WebMethod.class); WebMethod webMethod=(WebMethod)ann; assertEquals(webMethod.operationName(),"SayHi"); Annotation[][] paraAnns=method.getParameterAnnotations(); for ( Annotation[] paraType : paraAnns) { for ( Annotation an : paraType) { if (an.annotationType() == WebParam.class) { WebParam webParam=(WebParam)an; assertNotSame("",webParam.targetNamespace()); } } } }

Class: org.apache.cxf.systest.callback.CallbackClientServerTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testCallback() throws Exception { Object implementor=new CallbackImpl(); String address="http://localhost:" + CB_PORT + "/CallbackContext/CallbackPort"; Endpoint ep=Endpoint.publish(address,implementor); URL wsdlURL=getClass().getResource("/wsdl/basic_callback_test.wsdl"); SOAPService ss=new SOAPService(wsdlURL,SERVICE_NAME); ServerPortType port=ss.getPort(PORT_NAME,ServerPortType.class); updateAddressPort(port,PORT); EndpointReference w3cEpr=ep.getEndpointReference(); String resp=port.registerCallback((W3CEndpointReference)w3cEpr); assertEquals("registerCallback called",resp); ep.stop(); }

Class: org.apache.cxf.systest.clustering.LoadDistributorAddressOverrideTest

IterativeVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDistributedSequentialStrategyWithFailover() throws Exception { startTarget(REPLICA_A); startTarget(REPLICA_C); setupGreeterA(); verifyStrategy(greeter,SequentialStrategy.class,3); Map responseCounts=new HashMap(); for (int i=0; i < 12; ++i) { String response=greeter.greetMe("fred"); assertNotNull("expected non-null response",response); incrementResponseCount(responseCounts,response); } assertEquals(8,(long)responseCounts.get(REPLICA_A)); assertEquals(null,responseCounts.get(REPLICA_B)); assertEquals(4,(long)responseCounts.get(REPLICA_C)); verifyCurrentEndpoint(REPLICA_C); stopTarget(REPLICA_A); stopTarget(REPLICA_C); }

IterativeVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDistributedSequentialStrategy() throws Exception { startTarget(REPLICA_A); startTarget(REPLICA_B); startTarget(REPLICA_C); setupGreeterA(); verifyStrategy(greeter,SequentialStrategy.class,3); Map responseCounts=new HashMap(); for (int i=0; i < 12; ++i) { String response=greeter.greetMe("fred"); assertNotNull("expected non-null response",response); incrementResponseCount(responseCounts,response); } assertEquals(4,(long)responseCounts.get(REPLICA_A)); assertEquals(4,(long)responseCounts.get(REPLICA_B)); assertEquals(4,(long)responseCounts.get(REPLICA_C)); verifyCurrentEndpoint(REPLICA_C); stopTarget(REPLICA_A); stopTarget(REPLICA_B); stopTarget(REPLICA_C); }

IterativeVerifier BranchVerifier UtilityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDistributedSequentialStrategyWithoutFailover() throws Exception { startTarget(REPLICA_A); startTarget(REPLICA_C); setupGreeterA(); verifyStrategy(greeter,SequentialStrategy.class,3); ConduitSelector conduitSelector=ClientProxy.getClient(greeter).getConduitSelector(); if (conduitSelector instanceof LoadDistributorTargetSelector) { ((LoadDistributorTargetSelector)conduitSelector).setFailover(false); } else { fail("unexpected conduit selector: " + conduitSelector); } Map responseCounts=new HashMap(); for (int i=0; i < 12; ++i) { try { String response=greeter.greetMe("fred"); assertNotNull("expected non-null response",response); incrementResponseCount(responseCounts,response); } catch ( WebServiceException ex) { incrementResponseCount(responseCounts,""); } } assertEquals(4,(long)responseCounts.get(REPLICA_A)); assertEquals(null,responseCounts.get(REPLICA_B)); assertEquals(4,(long)responseCounts.get(REPLICA_C)); assertEquals(4,(long)responseCounts.get("")); verifyCurrentEndpoint(REPLICA_C); stopTarget(REPLICA_A); stopTarget(REPLICA_C); }

Class: org.apache.cxf.systest.clustering.LoadDistributorTest

IterativeVerifier BranchVerifier UtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDistributedSequentialStrategyWithFailover() throws Exception { startTarget(REPLICA_A); startTarget(REPLICA_B); startTarget(REPLICA_C); setupGreeter(); stopTarget(REPLICA_B); ConduitSelector conduitSelector=ClientProxy.getClient(greeter).getConduitSelector(); if (conduitSelector instanceof LoadDistributorTargetSelector) { ((LoadDistributorTargetSelector)conduitSelector).setStrategy(new LoadDistributorStaticStrategy()); } else { fail("unexpected conduit selector: " + conduitSelector); } Map responseCounts=new HashMap(); for (int i=0; i < 12; ++i) { String response=greeter.greetMe("fred"); assertNotNull("expected non-null response",response); incrementResponseCount(responseCounts,response); } assertTrue((long)responseCounts.get(REPLICA_A) > 0); assertTrue((long)responseCounts.get(REPLICA_C) > 0); assertEquals(12,responseCounts.get(REPLICA_A) + responseCounts.get(REPLICA_C)); stopTarget(REPLICA_A); stopTarget(REPLICA_C); }

IterativeVerifier BranchVerifier UtilityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDistributedSequentialStrategy() throws Exception { startTarget(REPLICA_A); startTarget(REPLICA_B); startTarget(REPLICA_C); startTarget(REPLICA_E); setupGreeter(); ConduitSelector conduitSelector=ClientProxy.getClient(greeter).getConduitSelector(); if (conduitSelector instanceof LoadDistributorTargetSelector) { ((LoadDistributorTargetSelector)conduitSelector).setStrategy(new LoadDistributorStaticStrategy()); } else { fail("unexpected conduit selector: " + conduitSelector); } Map responseCounts=new HashMap(); for (int i=0; i < 12; ++i) { String response=greeter.greetMe("fred"); assertNotNull("expected non-null response",response); incrementResponseCount(responseCounts,response); } assertEquals(3,(long)responseCounts.get(REPLICA_A)); assertEquals(3,(long)responseCounts.get(REPLICA_B)); assertEquals(3,(long)responseCounts.get(REPLICA_C)); assertEquals(3,(long)responseCounts.get(REPLICA_E)); stopTarget(REPLICA_A); stopTarget(REPLICA_B); stopTarget(REPLICA_C); stopTarget(REPLICA_E); }

IterativeVerifier BranchVerifier UtilityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDistributedSequentialStrategyWithoutFailover() throws Exception { startTarget(REPLICA_A); startTarget(REPLICA_B); startTarget(REPLICA_C); startTarget(REPLICA_E); setupGreeter(); stopTarget(REPLICA_B); ConduitSelector conduitSelector=ClientProxy.getClient(greeter).getConduitSelector(); if (conduitSelector instanceof LoadDistributorTargetSelector) { ((LoadDistributorTargetSelector)conduitSelector).setStrategy(new LoadDistributorStaticStrategy()); ((LoadDistributorTargetSelector)conduitSelector).setFailover(false); } else { fail("unexpected conduit selector: " + conduitSelector); } Map responseCounts=new HashMap(); for (int i=0; i < 12; ++i) { try { String response=greeter.greetMe("fred"); assertNotNull("expected non-null response",response); incrementResponseCount(responseCounts,response); } catch ( WebServiceException ex) { incrementResponseCount(responseCounts,""); } } assertEquals(3,(long)responseCounts.get(REPLICA_A)); assertEquals(null,responseCounts.get(REPLICA_B)); assertEquals(3,(long)responseCounts.get(REPLICA_C)); assertEquals(3,(long)responseCounts.get(REPLICA_E)); assertEquals(3,(long)responseCounts.get("")); stopTarget(REPLICA_A); stopTarget(REPLICA_C); stopTarget(REPLICA_E); }

Class: org.apache.cxf.systest.cxf6319.Cxf6319TestCase

APIUtilityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDeclarationsInEnvelope() throws Exception { Endpoint ep=Endpoint.publish("http://localhost:" + PORT + "/SoapContext/SoapPort",new ServiceImpl()); try { HttpURLConnection httpConnection=getHttpConnection("http://localhost:" + PORT + "/SoapContext/SoapPort/echo"); httpConnection.setDoOutput(true); InputStream reqin=getClass().getResourceAsStream("request.xml"); assertNotNull("could not load test data",reqin); httpConnection.setRequestMethod("POST"); httpConnection.addRequestProperty("Content-Type","text/xml"); OutputStream reqout=httpConnection.getOutputStream(); IOUtils.copy(reqin,reqout); reqout.close(); int responseCode=httpConnection.getResponseCode(); InputStream errorStream=httpConnection.getErrorStream(); String error=null; if (errorStream != null) { error=IOUtils.readStringFromStream(errorStream); } assertEquals(error,200,responseCode); } catch ( Exception e) { e.printStackTrace(); } finally { ep.stop(); } }

Class: org.apache.cxf.systest.cxf993.Cxf993Test

EqualityVerifier 
@Test public void testBasicConnection() throws Exception { assertEquals("dummy",getPort().sendNotification(new SendNotification())); }

Class: org.apache.cxf.systest.dispatch.DispatchClientServerTest

APIUtilityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDOMSourcePAYLOAD() throws Exception { Service service=Service.create(SERVICE_NAME); assertNotNull(service); service.addPort(PORT_NAME,"http://schemas.xmlsoap.org/soap/","http://localhost:" + greeterPort + "/SOAPDispatchService/SoapDispatchPort"); Dispatch disp=service.createDispatch(PORT_NAME,DOMSource.class,Service.Mode.PAYLOAD); InputStream is=getClass().getResourceAsStream("resources/GreetMeDocLiteralReq.xml"); SOAPMessage soapReqMsg=MessageFactory.newInstance().createMessage(null,is); DOMSource domReqMsg=new DOMSource(soapReqMsg.getSOAPBody().extractContentAsDocument()); assertNotNull(domReqMsg); DOMSource domResMsg=disp.invoke(domReqMsg); assertNotNull(domResMsg); String expected="Hello TestSOAPInputMessage"; Node node=domResMsg.getNode(); assertNotNull(node); if (node instanceof Document) { node=((Document)node).getDocumentElement(); } String content=node.getTextContent(); assertNotNull(content); assertEquals("Response should be : Hello TestSOAPInputMessage",expected,content.trim()); InputStream is1=getClass().getResourceAsStream("resources/GreetMeDocLiteralReq1.xml"); SOAPMessage soapReqMsg1=MessageFactory.newInstance().createMessage(null,is1); DOMSource domReqMsg1=new DOMSource(soapReqMsg1.getSOAPBody().extractContentAsDocument()); assertNotNull(domReqMsg1); disp.invokeOneWay(domReqMsg1); InputStream is2=getClass().getResourceAsStream("resources/GreetMeDocLiteralReq2.xml"); SOAPMessage soapReqMsg2=MessageFactory.newInstance().createMessage(null,is2); DOMSource domReqMsg2=new DOMSource(soapReqMsg2.getSOAPBody().extractContentAsDocument()); assertNotNull(domReqMsg2); Response response=disp.invokeAsync(domReqMsg2); DOMSource domRespMsg2=response.get(); assertNotNull(domRespMsg2); String expected2="Hello TestSOAPInputMessage2"; node=domRespMsg2.getNode(); assertNotNull(node); if (node instanceof Document) { node=((Document)node).getDocumentElement(); } content=node.getTextContent(); assertNotNull(content); assertEquals("Response should be : Hello TestSOAPInputMessage2",expected2,content.trim()); InputStream is3=getClass().getResourceAsStream("resources/GreetMeDocLiteralReq3.xml"); SOAPMessage soapReqMsg3=MessageFactory.newInstance().createMessage(null,is3); DOMSource domReqMsg3=new DOMSource(soapReqMsg3.getSOAPBody().extractContentAsDocument()); assertNotNull(domReqMsg3); TestDOMSourceHandler tdsh=new TestDOMSourceHandler(); Future fd=disp.invokeAsync(domReqMsg3,tdsh); assertNotNull(fd); waitForFuture(fd); String expected3="Hello TestSOAPInputMessage3"; assertEquals("Response should be : Hello TestSOAPInputMessage3",expected3,tdsh.getReplyBuffer().trim()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testJAXBObjectPAYLOADWithFeature() throws Exception { createBus("org/apache/cxf/systest/dispatch/client-config.xml"); BusFactory.setThreadDefaultBus(bus); URL wsdl=getClass().getResource("/wsdl/hello_world.wsdl"); assertNotNull(wsdl); String bindingId="http://schemas.xmlsoap.org/wsdl/soap/"; String endpointUrl="http://localhost:" + greeterPort + "/SOAPDispatchService/SoapDispatchPort"; Service service=Service.create(wsdl,SERVICE_NAME); service.addPort(PORT_NAME,bindingId,endpointUrl); assertNotNull(service); JAXBContext jc=JAXBContext.newInstance("org.apache.hello_world_soap_http.types"); Dispatch disp=service.createDispatch(PORT_NAME,jc,Service.Mode.PAYLOAD); disp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,"http://localhost:" + greeterPort + "/SOAPDispatchService/SoapDispatchPort"); String expected="Hello Jeeves"; GreetMe greetMe=new GreetMe(); greetMe.setRequestType("Jeeves"); Object response=disp.invoke(greetMe); assertNotNull(response); String responseValue=((GreetMeResponse)response).getResponseType(); assertTrue("Expected string, " + expected,expected.equals(responseValue)); assertEquals("Feature should be applied",1,TestDispatchFeature.getCount()); assertEquals("Feature based interceptors should be added",1,TestDispatchFeature.getCount()); assertEquals("Feature based In interceptors has be added to in chain.",1,TestDispatchFeature.getInInterceptorCount()); assertEquals("Feature based interceptors has to be added to out chain.",1,TestDispatchFeature.getOutInterceptorCount()); bus.shutdown(true); }

APIUtilityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDOMSourceMESSAGE() throws Exception { Service service=Service.create(SERVICE_NAME); assertNotNull(service); service.addPort(PORT_NAME,"http://schemas.xmlsoap.org/soap/","http://localhost:" + greeterPort + "/SOAPDispatchService/SoapDispatchPort"); Dispatch disp=service.createDispatch(PORT_NAME,DOMSource.class,Service.Mode.MESSAGE); InputStream is=getClass().getResourceAsStream("resources/GreetMeDocLiteralReq.xml"); SOAPMessage soapReqMsg=MessageFactory.newInstance().createMessage(null,is); DOMSource domReqMsg=new DOMSource(soapReqMsg.getSOAPPart()); assertNotNull(domReqMsg); DOMSource domResMsg=disp.invoke(domReqMsg); assertNotNull(domResMsg); String expected="Hello TestSOAPInputMessage"; assertEquals("Response should be : Hello TestSOAPInputMessage",expected,DOMUtils.getAllContent(domResMsg.getNode().getFirstChild()).trim()); Element el=(Element)domResMsg.getNode().getFirstChild(); assertEquals("gmns",el.lookupPrefix("http://apache.org/hello_world_soap_http/types")); assertEquals("http://apache.org/hello_world_soap_http/types",el.lookupNamespaceURI("gmns")); InputStream is1=getClass().getResourceAsStream("resources/GreetMeDocLiteralReq1.xml"); SOAPMessage soapReqMsg1=MessageFactory.newInstance().createMessage(null,is1); DOMSource domReqMsg1=new DOMSource(soapReqMsg1.getSOAPPart()); assertNotNull(domReqMsg1); disp.invokeOneWay(domReqMsg1); InputStream is2=getClass().getResourceAsStream("resources/GreetMeDocLiteralReq2.xml"); SOAPMessage soapReqMsg2=MessageFactory.newInstance().createMessage(null,is2); DOMSource domReqMsg2=new DOMSource(soapReqMsg2.getSOAPPart()); assertNotNull(domReqMsg2); Response response=disp.invokeAsync(domReqMsg2); DOMSource domRespMsg2=response.get(); assertNotNull(domReqMsg2); String expected2="Hello TestSOAPInputMessage2"; assertEquals("Response should be : Hello TestSOAPInputMessage2",expected2,domRespMsg2.getNode().getFirstChild().getTextContent().trim()); InputStream is3=getClass().getResourceAsStream("resources/GreetMeDocLiteralReq3.xml"); SOAPMessage soapReqMsg3=MessageFactory.newInstance().createMessage(null,is3); DOMSource domReqMsg3=new DOMSource(soapReqMsg3.getSOAPPart()); assertNotNull(domReqMsg3); TestDOMSourceHandler tdsh=new TestDOMSourceHandler(); Future fd=disp.invokeAsync(domReqMsg3,tdsh); assertNotNull(fd); waitForFuture(fd); String expected3="Hello TestSOAPInputMessage3"; assertEquals("Response should be : Hello TestSOAPInputMessage3",expected3,tdsh.getReplyBuffer().trim()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCreateDispatchWithEPR() throws Exception { URL wsdl=getClass().getResource("/wsdl/hello_world.wsdl"); assertNotNull(wsdl); SOAPService service=new SOAPService(wsdl,SERVICE_NAME); assertNotNull(service); W3CEndpointReferenceBuilder builder=new W3CEndpointReferenceBuilder(); builder.address("http://localhost:" + greeterPort + "/SOAPDispatchService/SoapDispatchPort"); builder.serviceName(SERVICE_NAME); builder.endpointName(PORT_NAME); W3CEndpointReference w3cEpr=builder.build(); Dispatch disp=service.createDispatch(w3cEpr,SOAPMessage.class,Service.Mode.MESSAGE); InputStream is=getClass().getResourceAsStream("resources/GreetMeDocLiteralReq.xml"); SOAPMessage soapReqMsg=MessageFactory.newInstance().createMessage(null,is); assertNotNull(soapReqMsg); SOAPMessage soapResMsg=disp.invoke(soapReqMsg); assertNotNull(soapResMsg); String expected="Hello TestSOAPInputMessage"; assertEquals("Response should be : Hello TestSOAPInputMessage",expected,DOMUtils.getAllContent(SAAJUtils.getBody(soapResMsg)).trim()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSOAPMessage() throws Exception { URL wsdl=getClass().getResource("/wsdl/hello_world.wsdl"); assertNotNull(wsdl); SOAPService service=new SOAPService(wsdl,SERVICE_NAME); assertNotNull(service); Dispatch disp=service.createDispatch(PORT_NAME,SOAPMessage.class,Service.Mode.MESSAGE); disp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,"http://localhost:" + greeterPort + "/SOAPDispatchService/SoapDispatchPort"); InputStream is=getClass().getResourceAsStream("resources/GreetMeDocLiteralReq.xml"); SOAPMessage soapReqMsg=MessageFactory.newInstance().createMessage(null,is); assertNotNull(soapReqMsg); SOAPMessage soapResMsg=disp.invoke(soapReqMsg); assertNotNull(soapResMsg); String expected="Hello TestSOAPInputMessage"; assertEquals("Response should be : Hello TestSOAPInputMessage",expected,DOMUtils.getContent(SAAJUtils.getBody(soapResMsg).getFirstChild().getFirstChild()).trim()); InputStream is1=getClass().getResourceAsStream("resources/GreetMe1WDocLiteralReq2.xml"); SOAPMessage soapReqMsg1=MessageFactory.newInstance().createMessage(null,is1); assertNotNull(soapReqMsg1); disp.invokeOneWay(soapReqMsg1); InputStream is2=getClass().getResourceAsStream("resources/GreetMeDocLiteralReq2.xml"); SOAPMessage soapReqMsg2=MessageFactory.newInstance().createMessage(null,is2); assertNotNull(soapReqMsg2); Response response=disp.invokeAsync(soapReqMsg2); SOAPMessage soapResMsg2=(SOAPMessage)response.get(); assertNotNull(soapResMsg2); String expected2="Hello TestSOAPInputMessage2"; assertEquals("Response should be : Hello TestSOAPInputMessage2",expected2,DOMUtils.getContent(SAAJUtils.getBody(soapResMsg2).getFirstChild().getFirstChild())); InputStream is3=getClass().getResourceAsStream("resources/GreetMeDocLiteralReq3.xml"); SOAPMessage soapReqMsg3=MessageFactory.newInstance().createMessage(null,is3); assertNotNull(soapReqMsg3); TestSOAPMessageHandler tsmh=new TestSOAPMessageHandler(); Future f=disp.invokeAsync(soapReqMsg3,tsmh); assertNotNull(f); waitForFuture(f); String expected3="Hello TestSOAPInputMessage3"; assertEquals("Response should be : Hello TestSOAPInputMessage3",expected3,tsmh.getReplyBuffer().trim()); }

Class: org.apache.cxf.systest.dispatch.DispatchClientServerWithMalformedResponseTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSOAPMessageWithMalformedResponse() throws Exception { URL wsdl=getClass().getResource("/wsdl/hello_world.wsdl"); assertNotNull(wsdl); SOAPService service=new SOAPService(wsdl,SERVICE_NAME); assertNotNull(service); Dispatch disp=service.createDispatch(PORT_NAME,SOAPMessage.class,Service.Mode.MESSAGE); disp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,"http://localhost:" + greeterPort + "/SOAPDispatchService/SoapDispatchPort"); InputStream is3=getClass().getResourceAsStream("resources/GreetMeDocLiteralReq3.xml"); SOAPMessage soapReqMsg3=MessageFactory.newInstance().createMessage(null,is3); assertNotNull(soapReqMsg3); TestSOAPMessageHandler tsmh=new TestSOAPMessageHandler(); Future f=disp.invokeAsync(soapReqMsg3,tsmh); assertNotNull(f); waitForFuture(f); assertEquals("AsyncHandler shouldn't get invoked more than once",asyncHandlerInvokedCount,1); }

Class: org.apache.cxf.systest.dispatch.DispatchXMLClientServerTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testStreamSourceMESSAGE() throws Exception { Service service=Service.create(SERVICE_NAME); assertNotNull(service); service.addPort(PORT_NAME,"http://cxf.apache.org/bindings/xformat","http://localhost:" + port + "/XMLService/XMLDispatchPort"); InputStream is=getClass().getResourceAsStream("/messages/XML_GreetMeDocLiteralReq.xml"); StreamSource reqMsg=new StreamSource(is); assertNotNull(reqMsg); Dispatch disp=service.createDispatch(PORT_NAME,Source.class,Service.Mode.MESSAGE); Source source=disp.invoke(reqMsg); assertNotNull(source); String streamString=StaxUtils.toString(source); Document doc=StaxUtils.read(new StringReader(streamString)); assertEquals("greetMeResponse",doc.getFirstChild().getLocalName()); assertEquals("Hello tli",doc.getFirstChild().getTextContent()); }

APIUtilityVerifier UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testJAXBMESSAGE() throws Exception { Service service=Service.create(SERVICE_NAME); assertNotNull(service); service.addPort(PORT_NAME,"http://cxf.apache.org/bindings/xformat","http://localhost:" + port + "/XMLService/XMLDispatchPort"); GreetMe gm=new GreetMe(); gm.setRequestType("CXF"); JAXBContext ctx=JAXBContext.newInstance(ObjectFactory.class); Dispatch disp=service.createDispatch(PORT_NAME,ctx,Service.Mode.MESSAGE); GreetMeResponse resp=(GreetMeResponse)disp.invoke(gm); assertNotNull(resp); assertEquals("Hello CXF",resp.getResponseType()); try { disp.invoke(null); fail("Should have thrown a fault"); } catch ( WebServiceException ex) { } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDOMSourcePAYLOAD() throws Exception { URL wsdl=getClass().getResource("/wsdl/hello_world_xml_wrapped.wsdl"); assertNotNull(wsdl); XMLService service=new XMLService(wsdl,SERVICE_NAME); assertNotNull(service); InputStream is=getClass().getResourceAsStream("/messages/XML_GreetMeDocLiteralReq.xml"); Document doc=StaxUtils.read(is); DOMSource reqMsg=new DOMSource(doc); assertNotNull(reqMsg); Dispatch disp=service.createDispatch(PORT_NAME,DOMSource.class,Service.Mode.PAYLOAD); disp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,"http://localhost:" + port + "/XMLService/XMLDispatchPort"); DOMSource result=disp.invoke(reqMsg); assertNotNull(result); Node respDoc=result.getNode(); assertEquals("greetMeResponse",respDoc.getFirstChild().getLocalName()); assertEquals("Hello tli",respDoc.getFirstChild().getTextContent()); }

Class: org.apache.cxf.systest.exception.GenericExceptionTest

APIUtilityVerifier UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGenericException() throws Exception { String address="http://localhost:" + PORT + "/generic"; URL wsdlURL=new URL(address + "?wsdl"); InputStream ins=wsdlURL.openStream(); Document doc=StaxUtils.read(ins); Map ns=new HashMap(); ns.put("xsd","http://www.w3.org/2001/XMLSchema"); ns.put("wsdl","http://schemas.xmlsoap.org/wsdl/"); ns.put("tns","http://cxf.apache.org/test/HelloService"); XPathUtils xpu=new XPathUtils(ns); Node nd=xpu.getValueNode("//xsd:complexType[@name='objectWithGenerics']",doc); assertNotNull(nd); assertNotNull(xpu.getValueNode("//xsd:element[@name='a']",nd)); assertNotNull(xpu.getValueNode("//xsd:element[@name='b']",nd)); Service service=Service.create(wsdlURL,serviceName); service.addPort(new QName("http://cxf.apache.org/test/HelloService","HelloPort"),SOAPBinding.SOAP11HTTP_BINDING,address); GenericsEcho port=service.getPort(new QName("http://cxf.apache.org/test/HelloService","HelloPort"),GenericsEcho.class); try { port.echo("test"); fail("Exception is expected"); } catch ( GenericsException e) { ObjectWithGenerics genericObj=e.getObj(); assertEquals(true,genericObj.getA()); assertEquals(100,genericObj.getB().intValue()); } }

Class: org.apache.cxf.systest.fault.IntFaultClientServerTest

EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBasicConnection() throws Exception { URL wsdl=getClass().getResource("/wsdl/hello_world_fault.wsdl"); assertNotNull("WSDL is null",wsdl); SOAPService service=new SOAPService(wsdl,serviceName); assertNotNull("Service is null",service); Greeter greeter=service.getSoapPort(); ClientProxy.getClient(greeter).getInInterceptors().add(new LoggingInInterceptor()); ClientProxy.getClient(greeter).getOutInterceptors().add(new LoggingOutInterceptor()); updateAddressPort(greeter,PORT); try { greeter.testDocLitFault("fault"); } catch ( BadRecordLitFault e) { assertEquals(5,e.getFaultInfo()); assertSoapHeader((BindingProvider)greeter); } }

Class: org.apache.cxf.systest.handlers.DispatchHandlerInvocationTest

UtilityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testInvokeWithDataSourcPayloadModeXMLBinding() throws Exception { URL wsdl=getClass().getResource("/wsdl/addNumbers.wsdl"); assertNotNull(wsdl); XMLService service=new XMLService(); assertNotNull(service); Dispatch disp=service.createDispatch(portNameXML,DataSource.class,Mode.PAYLOAD); setAddress(disp,addNumbersAddress); TestHandlerXMLBinding handler=new TestHandlerXMLBinding(); addHandlersProgrammatically(disp,handler); URL is=getClass().getResource("/messages/XML_GreetMeDocLiteralReq.xml"); DataSource ds=new URLDataSource(is); try { disp.invoke(ds); fail("Did not get expected exception"); } catch ( HTTPException e) { assertEquals(e.getCause().getMessage(),"DataSource is not valid in PAYLOAD mode with XML/HTTP binding."); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testInvokeWithJAXBMessageModeXMLBinding() throws Exception { URL wsdl=getClass().getResource("/wsdl/addNumbers.wsdl"); assertNotNull(wsdl); XMLService service=new XMLService(); assertNotNull(service); JAXBContext jc=JAXBContext.newInstance("org.apache.hello_world_xml_http.wrapped.types"); Dispatch disp=service.createDispatch(portNameXML,jc,Mode.MESSAGE); setAddress(disp,greeterAddress); TestHandlerXMLBinding handler=new TestHandlerXMLBinding(); addHandlersProgrammatically(disp,handler); org.apache.hello_world_xml_http.wrapped.types.GreetMe req=new org.apache.hello_world_xml_http.wrapped.types.GreetMe(); req.setRequestType("tli"); Object response=disp.invoke(req); assertNotNull(response); org.apache.hello_world_xml_http.wrapped.types.GreetMeResponse value=(org.apache.hello_world_xml_http.wrapped.types.GreetMeResponse)response; assertEquals("Hello tli",value.getResponseType()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testInvokeWithJAXBPayloadModeXMLBinding() throws Exception { URL wsdl=getClass().getResource("/wsdl/addNumbers.wsdl"); assertNotNull(wsdl); XMLService service=new XMLService(); assertNotNull(service); JAXBContext jc=JAXBContext.newInstance("org.apache.hello_world_xml_http.wrapped.types"); Dispatch disp=service.createDispatch(portNameXML,jc,Mode.PAYLOAD); setAddress(disp,greeterAddress); TestHandlerXMLBinding handler=new TestHandlerXMLBinding(); addHandlersProgrammatically(disp,handler); org.apache.hello_world_xml_http.wrapped.types.GreetMe req=new org.apache.hello_world_xml_http.wrapped.types.GreetMe(); req.setRequestType("tli"); Object response=disp.invoke(req); assertNotNull(response); org.apache.hello_world_xml_http.wrapped.types.GreetMeResponse value=(org.apache.hello_world_xml_http.wrapped.types.GreetMeResponse)response; assertEquals("Hello tli",value.getResponseType()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testInvokeWithJAXBUnwrapPayloadMode() throws Exception { URL wsdl=getClass().getResource("/wsdl/addNumbers.wsdl"); assertNotNull(wsdl); org.apache.cxf.systest.handlers.AddNumbersServiceUnwrap service=new org.apache.cxf.systest.handlers.AddNumbersServiceUnwrap(wsdl,serviceName); assertNotNull(service); JAXBContext jc=JAXBContext.newInstance(org.apache.cxf.systest.handlers.types.AddNumbers.class,org.apache.cxf.systest.handlers.types.AddNumbersResponse.class); Dispatch disp=service.createDispatch(portName,jc,Service.Mode.PAYLOAD); setAddress(disp,addNumbersAddress); TestHandler handler=new TestHandler(); TestSOAPHandler soapHandler=new TestSOAPHandler(); addHandlersProgrammatically(disp,handler,soapHandler); org.apache.cxf.systest.handlers.types.AddNumbers req=new org.apache.cxf.systest.handlers.types.AddNumbers(); req.setArg0(10); req.setArg1(20); org.apache.cxf.systest.handlers.types.AddNumbersResponse response=(org.apache.cxf.systest.handlers.types.AddNumbersResponse)disp.invoke(req); assertNotNull(response); assertEquals(222,response.getReturn()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testInvokeWithJAXBPayloadMode() throws Exception { URL wsdl=getClass().getResource("/wsdl/addNumbers.wsdl"); assertNotNull(wsdl); AddNumbersService service=new AddNumbersService(wsdl,serviceName); assertNotNull(service); JAXBContext jc=JAXBContext.newInstance("org.apache.handlers.types"); Dispatch disp=service.createDispatch(portName,jc,Service.Mode.PAYLOAD); setAddress(disp,addNumbersAddress); TestHandler handler=new TestHandler(); TestSOAPHandler soapHandler=new TestSOAPHandler(); addHandlersProgrammatically(disp,handler,soapHandler); org.apache.handlers.types.AddNumbers req=new org.apache.handlers.types.AddNumbers(); req.setArg0(10); req.setArg1(20); ObjectFactory factory=new ObjectFactory(); JAXBElement e=factory.createAddNumbers(req); JAXBElement response=(JAXBElement)disp.invoke(e); assertNotNull(response); AddNumbersResponse value=(AddNumbersResponse)response.getValue(); assertEquals(222,value.getReturn()); }

Class: org.apache.cxf.systest.handlers.HandlerInvocationTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testSOAPHandlerHandleMessageReturnFalseClientInbound() throws Exception { TestHandler handler1=new TestHandler(false); TestHandler handler2=new TestHandler(false); TestSOAPHandler soapHandler1=new TestSOAPHandler(false); TestSOAPHandler soapHandler2=new TestSOAPHandler(false){ public boolean handleMessage( SOAPMessageContext ctx){ super.handleMessage(ctx); Boolean outbound=(Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (!outbound) { return false; } return true; } } ; addHandlersToChain((BindingProvider)handlerTest,handler1,handler2,soapHandler1,soapHandler2); handlerTest.ping(); assertEquals(1,handler1.getHandleMessageInvoked()); assertEquals(1,handler2.getHandleMessageInvoked()); assertEquals(1,soapHandler1.getHandleMessageInvoked()); assertEquals(2,soapHandler2.getHandleMessageInvoked()); assertEquals("close must be called",1,handler1.getCloseInvoked()); assertEquals("close must be called",1,handler2.getCloseInvoked()); assertEquals("close must be called",1,soapHandler1.getCloseInvoked()); assertEquals("close must be called",1,soapHandler2.getCloseInvoked()); assertTrue(soapHandler2.getInvokeOrderOfClose() < soapHandler1.getInvokeOrderOfClose()); assertTrue(soapHandler1.getInvokeOrderOfClose() < handler2.getInvokeOrderOfClose()); assertTrue(handler2.getInvokeOrderOfClose() < handler1.getInvokeOrderOfClose()); }

InternalCallVerifier EqualityVerifier 
@Test public void testLogicHandlerHandleMessageReturnFalseServerOutbound() throws PingException { String[] expectedHandlers={"server handler1 outbound stop","soapHandler4","soapHandler3","handler2","handler1","handler1"}; List resp=handlerTest.pingWithArgs("server handler1 outbound stop"); assertEquals(expectedHandlers.length,resp.size()); int i=0; for ( String expected : expectedHandlers) { assertEquals(expected,resp.get(i++)); } }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDescription() throws PingException { TestHandler handler=new TestHandler(false){ public boolean handleMessage( LogicalMessageContext ctx){ super.handleMessage(ctx); assertTrue("wsdl description not found or invalid",isValidWsdlDescription(ctx.get(MessageContext.WSDL_DESCRIPTION))); return true; } } ; TestSOAPHandler soapHandler=new TestSOAPHandler(false){ public boolean handleMessage( SOAPMessageContext ctx){ super.handleMessage(ctx); assertTrue("wsdl description not found or invalid",isValidWsdlDescription(ctx.get(MessageContext.WSDL_DESCRIPTION))); return true; } } ; addHandlersToChain((BindingProvider)handlerTest,handler,soapHandler); List resp=handlerTest.ping(); assertNotNull(resp); assertEquals("handler was not invoked",2,handler.getHandleMessageInvoked()); assertEquals("handle message was not invoked",2,soapHandler.getHandleMessageInvoked()); assertTrue("close must be called",handler.isCloseInvoked()); assertTrue("close must be called",soapHandler.isCloseInvoked()); }

APIUtilityVerifier BranchVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSOAPHandlerHandleMessageReturnTrueClient() throws Exception { TestHandler handler1=new TestHandler(false); TestHandler handler2=new TestHandler(false){ public boolean handleMessage( LogicalMessageContext ctx){ super.handleMessage(ctx); try { Boolean outbound=(Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (!outbound) { LogicalMessage msg=ctx.getMessage(); Source source=msg.getPayload(); assertNotNull(source); } } catch ( Exception e) { e.printStackTrace(); fail(e.toString()); } return true; } } ; TestSOAPHandler soapHandler1=new TestSOAPHandler(false); TestSOAPHandler soapHandler2=new TestSOAPHandler(false); addHandlersToChain((BindingProvider)handlerTest,handler1,handler2,soapHandler1,soapHandler2); List resp=handlerTest.ping(); assertNotNull(resp); assertEquals("handle message was not invoked",2,handler1.getHandleMessageInvoked()); assertEquals("handle message was not invoked",2,handler2.getHandleMessageInvoked()); assertEquals("handle message was not invoked",2,soapHandler1.getHandleMessageInvoked()); assertEquals("handle message was not invoked",2,soapHandler2.getHandleMessageInvoked()); assertEquals("close must be called",1,handler1.getCloseInvoked()); assertEquals("close must be called",1,handler2.getCloseInvoked()); assertEquals("close must be called",1,soapHandler1.getCloseInvoked()); assertEquals("close must be called",1,soapHandler2.getCloseInvoked()); assertTrue(soapHandler2.getInvokeOrderOfClose() < soapHandler1.getInvokeOrderOfClose()); assertTrue(soapHandler1.getInvokeOrderOfClose() < handler2.getInvokeOrderOfClose()); assertTrue(handler2.getInvokeOrderOfClose() < handler1.getInvokeOrderOfClose()); String[] handlerNames={"soapHandler4","soapHandler3","handler2","handler1","servant","handler1","handler2","soapHandler3","soapHandler4"}; assertEquals(handlerNames.length,resp.size()); Iterator iter=resp.iterator(); for ( String expected : handlerNames) { assertEquals(expected,iter.next()); } }

APIUtilityVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testSOAPHandlerHandleMessageThrowsProtocolExceptionClientOutbound() throws Exception { final String clientHandlerMessage="handler1 client side"; TestHandler handler1=new TestHandler(false); TestHandler handler2=new TestHandler(false); TestSOAPHandler soapHandler1=new TestSOAPHandler(false){ public boolean handleMessage( SOAPMessageContext ctx){ super.handleMessage(ctx); Boolean outbound=(Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outbound) { throw new ProtocolException(clientHandlerMessage); } return true; } } ; TestSOAPHandler soapHandler2=new TestSOAPHandler(false); addHandlersToChain((BindingProvider)handlerTest,handler1,handler2,soapHandler1,soapHandler2); try { handlerTest.ping(); fail("did not get expected exception"); } catch ( ProtocolException e) { assertEquals(clientHandlerMessage,e.getMessage()); } assertEquals(1,handler1.getHandleMessageInvoked()); assertEquals(1,handler2.getHandleMessageInvoked()); assertEquals(1,soapHandler1.getHandleMessageInvoked()); assertEquals(0,soapHandler2.getHandleMessageInvoked()); assertEquals(1,handler2.getHandleFaultInvoked()); assertEquals(1,handler1.getHandleFaultInvoked()); assertEquals(0,soapHandler1.getHandleFaultInvoked()); assertEquals(0,soapHandler2.getHandleFaultInvoked()); assertEquals(1,handler1.getCloseInvoked()); assertEquals(1,handler2.getCloseInvoked()); assertEquals(1,soapHandler1.getCloseInvoked()); assertEquals(0,soapHandler2.getCloseInvoked()); assertTrue(handler2.getInvokeOrderOfClose() < handler1.getInvokeOrderOfClose()); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testSOAPHandlerHandleMessageThrowsRuntimeExceptionServerOutbound() throws PingException { try { handlerTest.pingWithArgs("soapHandler3 outbound throw RuntimeException"); fail("did not get expected exception"); } catch ( SOAPFaultException e) { assertEquals("HandleMessage throws exception",e.getMessage()); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testHandlersInvokedForDispatch() throws Exception { Dispatch disp=service.createDispatch(portName,SOAPMessage.class,Service.Mode.MESSAGE); setAddress(disp,"http://localhost:" + port + "/HandlerTest/SoapPort"); TestHandler handler1=new TestHandler(false); TestHandler handler2=new TestHandler(false); TestSOAPHandler soapHandler1=new TestSOAPHandler(false); TestSOAPHandler soapHandler2=new TestSOAPHandler(false); addHandlersToChain(disp,handler1,handler2,soapHandler1,soapHandler2); InputStream is=getClass().getResourceAsStream("PingReq.xml"); SOAPMessage outMsg=MessageFactory.newInstance().createMessage(null,is); SOAPMessage inMsg=disp.invoke(outMsg); assertNotNull(inMsg); assertEquals("handle message was not invoked",2,handler1.getHandleMessageInvoked()); assertEquals("handle message was not invoked",2,handler2.getHandleMessageInvoked()); assertEquals("handle message was not invoked",2,soapHandler1.getHandleMessageInvoked()); assertEquals("handle message was not invoked",2,soapHandler2.getHandleMessageInvoked()); assertEquals("close must be called",1,handler1.getCloseInvoked()); assertEquals("close must be called",1,handler2.getCloseInvoked()); assertEquals("close must be called",1,soapHandler1.getCloseInvoked()); assertEquals("close must be called",1,soapHandler2.getCloseInvoked()); String[] handlerNames={"soapHandler4","soapHandler3","handler2","handler1","servant","handler1","handler2","soapHandler3","soapHandler4"}; List resp=getHandlerNames(inMsg.getSOAPPart().getEnvelope().getBody()); assertEquals(handlerNames.length,resp.size()); Iterator iter=resp.iterator(); for ( String expected : handlerNames) { assertEquals(expected,iter.next()); } }

APIUtilityVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testLogicalHandlerHandleMessageThrowsRuntimeExceptionClientInbound() throws Exception { final String clientHandlerMessage="handler1 client side"; TestHandler handler1=new TestHandler(false); TestHandler handler2=new TestHandler(false){ public boolean handleMessage( LogicalMessageContext ctx){ super.handleMessage(ctx); Boolean outbound=(Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (!outbound) { throw new RuntimeException(clientHandlerMessage); } return true; } } ; TestSOAPHandler soapHandler1=new TestSOAPHandler(false); addHandlersToChain((BindingProvider)handlerTest,handler1,handler2,soapHandler1); try { handlerTest.ping(); fail("did not get expected exception"); } catch ( RuntimeException e) { assertTrue(e.getMessage().contains(clientHandlerMessage)); } assertEquals(1,handler1.getHandleMessageInvoked()); assertEquals(2,handler2.getHandleMessageInvoked()); assertEquals(2,soapHandler1.getHandleMessageInvoked()); assertEquals(0,handler2.getHandleFaultInvoked()); assertEquals(0,handler1.getHandleFaultInvoked()); assertEquals(0,soapHandler1.getHandleFaultInvoked()); assertEquals(1,handler1.getCloseInvoked()); assertEquals(1,handler2.getCloseInvoked()); assertEquals(1,soapHandler1.getCloseInvoked()); assertTrue(handler2.getInvokeOrderOfClose() < handler1.getInvokeOrderOfClose()); }

InternalCallVerifier EqualityVerifier 
@Test public void testSOAPHandlerHandleMessageReturnsFalseServerInbound() throws PingException { String[] expectedHandlers={"soapHandler4","soapHandler3","soapHandler4"}; List resp=handlerTest.pingWithArgs("soapHandler3 inbound stop"); assertEquals(expectedHandlers.length,resp.size()); int i=0; for ( String expected : expectedHandlers) { assertEquals(expected,resp.get(i++)); } }

APIUtilityVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testLogicalHandlerHandleMessageThrowsProtocolExceptionClientOutbound() throws Exception { final String clientHandlerMessage="handler1 client side"; TestHandler handler1=new TestHandler(false); TestHandler handler2=new TestHandler(false){ public boolean handleMessage( LogicalMessageContext ctx){ super.handleMessage(ctx); Boolean outbound=(Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outbound) { throw new ProtocolException(clientHandlerMessage); } return true; } } ; TestSOAPHandler soapHandler1=new TestSOAPHandler(false); addHandlersToChain((BindingProvider)handlerTest,handler1,handler2,soapHandler1); try { handlerTest.ping(); fail("did not get expected exception"); } catch ( ProtocolException e) { assertEquals(clientHandlerMessage,e.getMessage()); } assertEquals(1,handler1.getHandleMessageInvoked()); assertEquals(1,handler2.getHandleMessageInvoked()); assertEquals(0,soapHandler1.getHandleMessageInvoked()); assertEquals(0,handler2.getHandleFaultInvoked()); assertEquals(1,handler1.getHandleFaultInvoked()); assertEquals(0,soapHandler1.getHandleFaultInvoked()); assertEquals(1,handler1.getCloseInvoked()); assertEquals(1,handler2.getCloseInvoked()); assertEquals(0,soapHandler1.getCloseInvoked()); assertTrue(handler2.getInvokeOrderOfClose() < handler1.getInvokeOrderOfClose()); }

InternalCallVerifier EqualityVerifier PublicFieldVerifier 
@Test public void testAddHandlerThroughHandlerResolverClientSide() throws Exception { TestHandler handler1=new TestHandler(false); TestHandler handler2=new TestHandler(false); MyHandlerResolver myHandlerResolver=new MyHandlerResolver(handler1,handler2); service.setHandlerResolver(myHandlerResolver); HandlerTest handlerTestNew=service.getPort(portName,HandlerTest.class); setAddress(handlerTestNew,"http://localhost:" + port + "/HandlerTest/SoapPort"); handlerTestNew.pingOneWay(); String bindingID=myHandlerResolver.bindingID; assertEquals("http://schemas.xmlsoap.org/wsdl/soap/http",bindingID); assertEquals(1,handler1.getHandleMessageInvoked()); assertEquals(1,handler2.getHandleMessageInvoked()); JAXBContext context=JAXBContext.newInstance(org.apache.handler_test.types.ObjectFactory.class); Dispatch disp=service.createDispatch(portName,context,Service.Mode.PAYLOAD); setAddress(disp,"http://localhost:" + port + "/HandlerTest/SoapPort"); disp.invokeOneWay(new org.apache.handler_test.types.PingOneWay()); assertEquals(2,handler1.getHandleMessageInvoked()); assertEquals(2,handler2.getHandleMessageInvoked()); }

APIUtilityVerifier BranchVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testServerEndpointRemoteFault() throws PingException { TestHandler handler1=new TestHandler(false); TestHandler handler2=new TestHandler(false){ public boolean handleFault( LogicalMessageContext ctx){ super.handleFault(ctx); try { Boolean outbound=(Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (!outbound) { LogicalMessage msg=ctx.getMessage(); String payload=convertDOMToString(msg.getPayload()); assertTrue(payload.indexOf("" + "servant throws SOAPFaultException" + "") > -1); } } catch ( Exception e) { e.printStackTrace(); fail(e.toString()); } return true; } private String convertDOMToString( Source s) throws TransformerException { StringWriter stringWriter=new StringWriter(); StreamResult streamResult=new StreamResult(stringWriter); TransformerFactory transformerFactory=TransformerFactory.newInstance(); Transformer transformer=transformerFactory.newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT,"no"); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount","2"); transformer.setOutputProperty(OutputKeys.METHOD,"xml"); transformer.transform(s,streamResult); return stringWriter.toString(); } } ; TestSOAPHandler soapHandler1=new TestSOAPHandler(false); TestSOAPHandler soapHandler2=new TestSOAPHandler(false){ public boolean handleFault( SOAPMessageContext ctx){ super.handleFault(ctx); try { Boolean outbound=(Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (!outbound) { SOAPEnvelope env=ctx.getMessage().getSOAPPart().getEnvelope(); assertTrue("expected SOAPFault in SAAJ model",env.getBody().hasFault()); } } catch ( Exception e) { e.printStackTrace(); fail(e.toString()); } return true; } } ; addHandlersToChain((BindingProvider)handlerTest,handler1,handler2,soapHandler1,soapHandler2); try { handlerTest.pingWithArgs("servant throw SOAPFaultException"); fail("did not get expected Exception"); } catch ( SOAPFaultException sfe) { } assertEquals(1,handler1.getHandleMessageInvoked()); assertEquals(1,handler2.getHandleMessageInvoked()); assertEquals(1,soapHandler1.getHandleMessageInvoked()); assertEquals(1,soapHandler2.getHandleMessageInvoked()); assertEquals(1,handler2.getHandleFaultInvoked()); assertEquals(1,handler1.getHandleFaultInvoked()); assertEquals(1,soapHandler1.getHandleFaultInvoked()); assertEquals(1,soapHandler2.getHandleFaultInvoked()); assertEquals(1,handler1.getCloseInvoked()); assertEquals(1,handler2.getCloseInvoked()); assertEquals(1,soapHandler1.getCloseInvoked()); assertEquals(1,soapHandler2.getCloseInvoked()); assertTrue(handler2.getInvokeOrderOfClose() < handler1.getInvokeOrderOfClose()); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testSOAPHandlerHandleFaultThrowsRuntimeExceptionServerOutbound() throws PingException { try { handlerTest.pingWithArgs("soapHandler3 inbound throw ProtocolException " + "soapHandler4HandleFaultThrowsRunException"); fail("did not get expected WebServiceException"); } catch ( WebServiceException e) { assertEquals("soapHandler4 HandleFault throws RuntimeException",e.getMessage()); } }

APIUtilityVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testSOAPHandlerHandleMessageThrowsRuntimeExceptionClientOutbound() throws Exception { final String clientHandlerMessage="handler1 client side"; TestHandler handler1=new TestHandler(false); TestHandler handler2=new TestHandler(false); TestSOAPHandler soapHandler1=new TestSOAPHandler(false){ public boolean handleMessage( SOAPMessageContext ctx){ super.handleMessage(ctx); Boolean outbound=(Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outbound) { throw new RuntimeException(clientHandlerMessage); } return true; } } ; TestSOAPHandler soapHandler2=new TestSOAPHandler(false); addHandlersToChain((BindingProvider)handlerTest,handler1,handler2,soapHandler1,soapHandler2); try { handlerTest.ping(); fail("did not get expected exception"); } catch ( RuntimeException e) { assertTrue(e.getMessage().contains(clientHandlerMessage)); } assertEquals(1,handler1.getHandleMessageInvoked()); assertEquals(1,handler2.getHandleMessageInvoked()); assertEquals(1,soapHandler1.getHandleMessageInvoked()); assertEquals(0,soapHandler2.getHandleMessageInvoked()); assertEquals(0,handler2.getHandleFaultInvoked()); assertEquals(0,handler1.getHandleFaultInvoked()); assertEquals(0,soapHandler1.getHandleFaultInvoked()); assertEquals(0,soapHandler2.getHandleFaultInvoked()); assertEquals(1,handler1.getCloseInvoked()); assertEquals(1,handler2.getCloseInvoked()); assertEquals(1,soapHandler1.getCloseInvoked()); assertEquals(0,soapHandler2.getCloseInvoked()); assertTrue(handler2.getInvokeOrderOfClose() < handler1.getInvokeOrderOfClose()); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testSOAPHandlerHandleFaultThrowsSOAPFaultExceptionServerOutbound() throws PingException { try { handlerTest.pingWithArgs("soapHandler3 inbound throw ProtocolException " + "soapHandler4HandleFaultThrowsSOAPFaultException"); fail("did not get expected SOAPFaultException"); } catch ( SOAPFaultException e) { assertEquals("soapHandler4 HandleFault throws SOAPFaultException",e.getMessage()); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testAddingUnusedHandlersThroughConfigFile(){ HandlerTestServiceWithAnnotation service1=new HandlerTestServiceWithAnnotation(wsdl,serviceName); HandlerTest handlerTest1=service1.getPort(portName,HandlerTest.class); BindingProvider bp1=(BindingProvider)handlerTest1; Binding binding1=bp1.getBinding(); @SuppressWarnings("rawtypes") List port1HandlerChain=binding1.getHandlerChain(); assertEquals(1,port1HandlerChain.size()); }

InternalCallVerifier EqualityVerifier 
@Test public void testLogicalHandlerHandleMessageReturnsFalseServerInbound() throws PingException { String[] expectedHandlers={"soapHandler4","soapHandler3","handler2","soapHandler3","soapHandler4"}; List resp=handlerTest.pingWithArgs("handler2 inbound stop"); assertEquals(expectedHandlers.length,resp.size()); int i=0; for ( String expected : expectedHandlers) { assertEquals(expected,resp.get(i++)); } }

InternalCallVerifier EqualityVerifier 
@Test public void testSOAPHandlerHandleMessageReturnsFalseServerOutbound() throws PingException { String[] expectedHandlers={"soapHandler3 outbound stop","soapHandler4","soapHandler3","handler2","handler1","handler1","handler2","soapHandler3"}; List resp=handlerTest.pingWithArgs("soapHandler3 outbound stop"); assertEquals(expectedHandlers.length,resp.size()); int i=0; for ( String expected : expectedHandlers) { assertEquals(expected,resp.get(i++)); } }

EqualityVerifier 
@Test public void testLogicalHandlerTwoWay() throws Exception { TestHandler handler1=new TestHandler(false); TestHandler handler2=new TestHandler(false); addHandlersToChain((BindingProvider)handlerTest,handler1,handler2); handlerTest.pingWithArgs("hello"); assertEquals(2,handler1.getHandleMessageInvoked()); assertEquals(2,handler2.getHandleMessageInvoked()); }

EqualityVerifier 
@Test public void testLogicalHandlerOneWay(){ TestHandler handler1=new TestHandler(false); TestHandler handler2=new TestHandler(false); addHandlersToChain((BindingProvider)handlerTest,handler1,handler2); handlerTest.pingOneWay(); assertEquals(1,handler1.getHandleMessageInvoked()); assertEquals(1,handler2.getHandleMessageInvoked()); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testSOAPHandlerHandleMessageThrowsRuntimeExceptionServerInbound() throws PingException { try { handlerTest.pingWithArgs("soapHandler3 inbound throw RuntimeException"); fail("did not get expected exception"); } catch ( SOAPFaultException e) { assertEquals("HandleMessage throws exception",e.getMessage()); } }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testLogicalHandlerHandleMessageReturnFalseClientInBound() throws Exception { TestHandler handler1=new TestHandler(false); TestHandler handler2=new TestHandler(false){ public boolean handleMessage( LogicalMessageContext ctx){ super.handleMessage(ctx); Boolean outbound=(Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (!outbound) { return false; } return true; } } ; TestHandler handler3=new TestHandler(false); TestSOAPHandler soapHandler1=new TestSOAPHandler(false); addHandlersToChain((BindingProvider)handlerTest,handler1,handler2,handler3,soapHandler1); handlerTest.ping(); assertEquals(1,handler1.getHandleMessageInvoked()); assertEquals(2,handler2.getHandleMessageInvoked()); assertEquals(2,handler3.getHandleMessageInvoked()); assertEquals(2,soapHandler1.getHandleMessageInvoked()); assertEquals("close must be called",1,handler1.getCloseInvoked()); assertEquals("close must be called",1,handler2.getCloseInvoked()); assertEquals("close must be called",1,handler3.getCloseInvoked()); assertEquals("close must be called",1,soapHandler1.getCloseInvoked()); assertTrue(soapHandler1.getInvokeOrderOfClose() < handler3.getInvokeOrderOfClose()); assertTrue(handler3.getInvokeOrderOfClose() < handler2.getInvokeOrderOfClose()); assertTrue(handler2.getInvokeOrderOfClose() < handler1.getInvokeOrderOfClose()); }

APIUtilityVerifier UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSOAPHandlerHandleMessageThrowsSOAPFaultExceptionServerInbound() throws PingException { try { handlerTest.pingWithArgs("soapHandler3 inbound throw SOAPFaultExceptionWDetail"); fail("did not get expected SOAPFaultException"); } catch ( SOAPFaultException e) { assertEquals("HandleMessage throws exception",e.getMessage()); SOAPFault fault=e.getFault(); assertNotNull(fault); assertEquals(new QName(SOAPConstants.URI_NS_SOAP_ENVELOPE,"Server"),fault.getFaultCodeAsQName()); assertEquals("http://gizmos.com/orders",fault.getFaultActor()); Detail detail=fault.getDetail(); assertNotNull(detail); QName nn=new QName("http://gizmos.com/orders/","order"); Element el=DOMUtils.getFirstChildWithName(detail,nn); assertNotNull(el); el.normalize(); assertEquals("Quantity element does not have a value",el.getFirstChild().getNodeValue()); el=DOMUtils.getNextElement(el); el.normalize(); assertEquals("Incomplete address: no zip code",el.getFirstChild().getNodeValue()); } }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testSOAPHandlerHandleMessageThrowsProtocolExceptionServerInbound() throws PingException { try { handlerTest.pingWithArgs("soapHandler3 inbound throw ProtocolException"); fail("did not get expected WebServiceException"); } catch ( WebServiceException e) { assertEquals("HandleMessage throws exception",e.getMessage()); } }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testSOAPHandlerHandleMessageThrowsProtocolExceptionServerOutbound() throws PingException { try { handlerTest.pingWithArgs("soapHandler3 outbound throw ProtocolException"); fail("did not get expected WebServiceException"); } catch ( WebServiceException e) { assertEquals("HandleMessage throws exception",e.getMessage()); } }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testLogicalHandlerHandleMessageThrowsProtocolExceptionClientInbound() throws Exception { final String clientHandlerMessage="handler1 client side"; TestHandler handler1=new TestHandler(false); TestHandler handler2=new TestHandler(false){ public boolean handleMessage( LogicalMessageContext ctx){ super.handleMessage(ctx); Boolean outbound=(Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (!outbound) { throw new ProtocolException(clientHandlerMessage); } return true; } } ; TestSOAPHandler soapHandler1=new TestSOAPHandler(false); addHandlersToChain((BindingProvider)handlerTest,handler1,handler2,soapHandler1); try { handlerTest.ping(); } catch ( ProtocolException e) { assertEquals(clientHandlerMessage,e.getMessage()); } assertEquals(1,handler1.getHandleMessageInvoked()); assertEquals(2,handler2.getHandleMessageInvoked()); assertEquals(2,soapHandler1.getHandleMessageInvoked()); assertEquals(0,handler2.getHandleFaultInvoked()); assertEquals(0,handler1.getHandleFaultInvoked()); assertEquals(0,soapHandler1.getHandleFaultInvoked()); assertEquals(1,handler1.getCloseInvoked()); assertEquals(1,handler2.getCloseInvoked()); assertEquals(1,soapHandler1.getCloseInvoked()); assertTrue(handler2.getInvokeOrderOfClose() < handler1.getInvokeOrderOfClose()); }

APIUtilityVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testLogicalHandlerHandleMessageThrowsRuntimeExceptionClientOutbound() throws Exception { final String clientHandlerMessage="handler1 client side"; TestHandler handler1=new TestHandler(false); TestHandler handler2=new TestHandler(false){ public boolean handleMessage( LogicalMessageContext ctx){ super.handleMessage(ctx); Boolean outbound=(Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outbound) { throw new RuntimeException(clientHandlerMessage); } return true; } } ; TestSOAPHandler soapHandler1=new TestSOAPHandler(false); addHandlersToChain((BindingProvider)handlerTest,handler1,handler2,soapHandler1); try { handlerTest.ping(); fail("did not get expected exception"); } catch ( RuntimeException e) { assertTrue(e.getMessage().contains(clientHandlerMessage)); } assertEquals(1,handler1.getHandleMessageInvoked()); assertEquals(1,handler2.getHandleMessageInvoked()); assertEquals(0,soapHandler1.getHandleMessageInvoked()); assertEquals(0,handler2.getHandleFaultInvoked()); assertEquals(0,handler1.getHandleFaultInvoked()); assertEquals(0,soapHandler1.getHandleFaultInvoked()); assertEquals(1,handler1.getCloseInvoked()); assertEquals(1,handler2.getCloseInvoked()); assertEquals(0,soapHandler1.getCloseInvoked()); assertTrue(handler2.getInvokeOrderOfClose() < handler1.getInvokeOrderOfClose()); }

APIUtilityVerifier BranchVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testLogicalHandlerHandleMessageReturnFalseClientOutBound() throws Exception { final String clientHandlerMessage="handler2 client side"; TestHandler handler1=new TestHandler(false); TestHandler handler2=new TestHandler(false){ public boolean handleMessage( LogicalMessageContext ctx){ super.handleMessage(ctx); try { Boolean outbound=(Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outbound) { LogicalMessage msg=ctx.getMessage(); assertNotNull("logical message is null",msg); JAXBContext jaxbCtx=JAXBContext.newInstance(PackageUtils.getPackageName(PingOneWay.class)); PingResponse resp=new PingResponse(); resp.getHandlersInfo().add(clientHandlerMessage); msg.setPayload(resp,jaxbCtx); return false; } } catch ( Exception e) { e.printStackTrace(); fail(e.toString()); } return true; } } ; TestHandler handler3=new TestHandler(false); TestSOAPHandler soapHandler1=new TestSOAPHandler(false); addHandlersToChain((BindingProvider)handlerTest,handler1,handler2,handler3,soapHandler1); List resp=handlerTest.ping(); assertEquals(clientHandlerMessage,resp.get(0)); assertEquals("the first handler must be invoked twice",2,handler1.getHandleMessageInvoked()); assertEquals("the second handler must be invoked once only on outbound",1,handler2.getHandleMessageInvoked()); assertEquals("the third handler must not be invoked",0,handler3.getHandleMessageInvoked()); assertEquals("the last handler must not be invoked",0,soapHandler1.getHandleMessageInvoked()); assertEquals("close must be called",1,handler1.getCloseInvoked()); assertEquals("close must be called",1,handler2.getCloseInvoked()); assertEquals("close must be called",0,handler3.getCloseInvoked()); assertEquals("close must be called",0,soapHandler1.getCloseInvoked()); assertTrue(handler2.getInvokeOrderOfClose() < handler1.getInvokeOrderOfClose()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testSOAPHandlerHandleMessageThrowsProtocolExceptionClientInbound() throws Exception { final String clientHandlerMessage="handler1 client side"; TestHandler handler1=new TestHandler(false); TestHandler handler2=new TestHandler(false); TestSOAPHandler soapHandler1=new TestSOAPHandler(false){ public boolean handleMessage( SOAPMessageContext ctx){ super.handleMessage(ctx); Boolean outbound=(Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (!outbound) { throw new ProtocolException(clientHandlerMessage); } return true; } } ; TestSOAPHandler soapHandler2=new TestSOAPHandler(false); addHandlersToChain((BindingProvider)handlerTest,handler1,handler2,soapHandler1,soapHandler2); try { handlerTest.ping(); } catch ( ProtocolException e) { assertEquals(clientHandlerMessage,e.getMessage()); } assertEquals(1,handler1.getHandleMessageInvoked()); assertEquals(1,handler2.getHandleMessageInvoked()); assertEquals(2,soapHandler1.getHandleMessageInvoked()); assertEquals(2,soapHandler2.getHandleMessageInvoked()); assertEquals(0,handler2.getHandleFaultInvoked()); assertEquals(0,handler1.getHandleFaultInvoked()); assertEquals(0,soapHandler1.getHandleFaultInvoked()); assertEquals(0,soapHandler2.getHandleFaultInvoked()); assertEquals(1,handler1.getCloseInvoked()); assertEquals(1,handler2.getCloseInvoked()); assertEquals(1,soapHandler1.getCloseInvoked()); assertEquals(1,soapHandler2.getCloseInvoked()); assertTrue(handler2.getInvokeOrderOfClose() < handler1.getInvokeOrderOfClose()); }

APIUtilityVerifier BranchVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSOAPHandlerHandleMessageReturnFalseClientOutbound() throws Exception { final String clientHandlerMessage="client side"; TestHandler handler1=new TestHandler(false); TestHandler handler2=new TestHandler(false){ public boolean handleMessage( LogicalMessageContext ctx){ super.handleMessage(ctx); try { Boolean outbound=(Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outbound) { LogicalMessage msg=ctx.getMessage(); assertNotNull("logical message is null",msg); JAXBContext jaxbCtx=JAXBContext.newInstance(PackageUtils.getPackageName(PingOneWay.class)); PingResponse resp=new PingResponse(); resp.getHandlersInfo().add(clientHandlerMessage); msg.setPayload(resp,jaxbCtx); } } catch ( Exception e) { e.printStackTrace(); fail(e.toString()); } return true; } } ; TestSOAPHandler soapHandler1=new TestSOAPHandler(false); TestSOAPHandler soapHandler2=new TestSOAPHandler(false){ public boolean handleMessage( SOAPMessageContext ctx){ super.handleMessage(ctx); Boolean outbound=(Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outbound) { return false; } return true; } } ; addHandlersToChain((BindingProvider)handlerTest,handler1,handler2,soapHandler1,soapHandler2); List resp=handlerTest.ping(); assertEquals(clientHandlerMessage,resp.get(0)); assertEquals(2,handler1.getHandleMessageInvoked()); assertEquals(2,handler2.getHandleMessageInvoked()); assertEquals(2,soapHandler1.getHandleMessageInvoked()); assertEquals(1,soapHandler2.getHandleMessageInvoked()); assertEquals("close must be called",1,handler1.getCloseInvoked()); assertEquals("close must be called",1,handler2.getCloseInvoked()); assertEquals("close must be called",1,soapHandler1.getCloseInvoked()); assertEquals("close must be called",1,soapHandler2.getCloseInvoked()); assertTrue(soapHandler2.getInvokeOrderOfClose() < soapHandler1.getInvokeOrderOfClose()); assertTrue(soapHandler1.getInvokeOrderOfClose() < handler2.getInvokeOrderOfClose()); assertTrue(handler2.getInvokeOrderOfClose() < handler1.getInvokeOrderOfClose()); }

Class: org.apache.cxf.systest.handlers.HandlerInvocationUsingAddNumbersTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testHandlerInjectingResource() throws Exception { Bus bus=BusFactory.getDefaultBus(); ResourceManager resourceManager=bus.getExtension(ResourceManager.class); assertNotNull(resourceManager); resourceManager.addResourceResolver(new TestResourceResolver()); URL wsdl=getClass().getResource("/wsdl/addNumbers.wsdl"); AddNumbersServiceWithAnnotation service=new AddNumbersServiceWithAnnotation(wsdl,serviceName); AddNumbers port=service.getPort(portName,AddNumbers.class); setAddress(port,addNumbersAddress); @SuppressWarnings("rawtypes") List handlerChain=((BindingProvider)port).getBinding().getHandlerChain(); SmallNumberHandler h=(SmallNumberHandler)handlerChain.get(0); assertEquals("injectedValue",h.getInjectedString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testAddHandlerProgrammaticallyClientSide() throws Exception { URL wsdl=getClass().getResource("/wsdl/addNumbers.wsdl"); AddNumbersService service=new AddNumbersService(wsdl,serviceName); AddNumbers port=service.getPort(portName,AddNumbers.class); setAddress(port,addNumbersAddress); SmallNumberHandler sh=new SmallNumberHandler(); addHandlersProgrammatically((BindingProvider)port,sh); int result=port.addNumbers(10,20); assertEquals(200,result); int result1=port.addNumbers(5,6); assertEquals(11,result1); }

APIUtilityVerifier BranchVerifier UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testInvokeFromDispatchWithJAXBPayload() throws Exception { URL wsdl=getClass().getResource("/wsdl/addNumbers.wsdl"); assertNotNull(wsdl); AddNumbersService service=new AddNumbersService(wsdl,serviceName); assertNotNull(service); JAXBContext jc=JAXBContext.newInstance("org.apache.handlers.types"); Dispatch disp=service.createDispatch(portName,jc,Service.Mode.PAYLOAD); setAddress(disp,addNumbersAddress); SmallNumberHandler sh=new SmallNumberHandler(); TestSOAPHandler soapHandler=new TestSOAPHandler(false){ public boolean handleMessage( SOAPMessageContext ctx){ super.handleMessage(ctx); Boolean outbound=(Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outbound) { try { SOAPMessage msg=ctx.getMessage(); assertNotNull(msg); } catch ( Exception e) { e.printStackTrace(); fail(e.toString()); } } return true; } } ; addHandlersProgrammatically(disp,sh,soapHandler); org.apache.handlers.types.AddNumbers req=new org.apache.handlers.types.AddNumbers(); req.setArg0(10); req.setArg1(20); ObjectFactory factory=new ObjectFactory(); JAXBElement e=factory.createAddNumbers(req); JAXBElement response=(JAXBElement)disp.invoke(e); assertNotNull(response); AddNumbersResponse value=(AddNumbersResponse)response.getValue(); assertEquals(200,value.getReturn()); }

InternalCallVerifier EqualityVerifier 
@Test public void testAddHandlerByAnnotationClientSide() throws Exception { URL wsdl=getClass().getResource("/wsdl/addNumbers.wsdl"); AddNumbersServiceWithAnnotation service=new AddNumbersServiceWithAnnotation(wsdl,serviceName); AddNumbers port=service.getPort(portName,AddNumbers.class); setAddress(port,addNumbersAddress); int result=port.addNumbers(10,20); assertEquals(200,result); int result1=port.addNumbers(5,6); assertEquals(11,result1); }

Class: org.apache.cxf.systest.handlers.SpringConfiguredAutoRewriteSoapAddressTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testWsdlAddress() throws Exception { AddNumbers addNumbers=getApplicationContext().getBean("cxfHandlerTestClientEndpoint",AddNumbers.class); int r=addNumbers.addNumbers(10,15); assertEquals(1015,r); List serviceUrls=findAllServiceUrlsFromWsdl("localhost",port); assertEquals(1,serviceUrls.size()); assertEquals("http://localhost:" + port + "/SpringEndpoint",serviceUrls.get(0)); String version=System.getProperty("java.version"); if (version.startsWith("1.8")) { return; } serviceUrls=findAllServiceUrlsFromWsdl("127.0.0.1",port); assertEquals(1,serviceUrls.size()); assertEquals("http://127.0.0.1:" + port + "/SpringEndpoint",serviceUrls.get(0)); }

Class: org.apache.cxf.systest.handlers.SpringConfiguredHandlerTest

InternalCallVerifier EqualityVerifier 
@Test public void testSpringConfiguresHandlers() throws Exception { AddNumbers addNumbers=getApplicationContext().getBean("cxfHandlerTestClientEndpoint",AddNumbers.class); int r=addNumbers.addNumbers(10,15); assertEquals(1015,r); addNumbers=getApplicationContext().getBean("cxfHandlerTestClientEndpointNoHandler",AddNumbers.class); r=addNumbers.addNumbers(10,15); assertEquals(115,r); addNumbers=getApplicationContext().getBean("cxfHandlerTestClientServer",AddNumbers.class); r=addNumbers.addNumbers(10,15); assertEquals(1015,r); }

Class: org.apache.cxf.systest.handlers.SpringConfiguredNoAutoRewriteSoapAddressTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testWsdlAddress() throws Exception { AddNumbers addNumbers=getApplicationContext().getBean("cxfHandlerTestClientEndpoint",AddNumbers.class); int r=addNumbers.addNumbers(10,15); assertEquals(1015,r); List serviceUrls=findAllServiceUrlsFromWsdl("localhost",port); assertEquals(1,serviceUrls.size()); assertEquals("http://localhost:" + port + "/SpringEndpoint",serviceUrls.get(0)); String version=System.getProperty("java.version"); if (version.startsWith("1.8")) { return; } serviceUrls=findAllServiceUrlsFromWsdl("127.0.0.1",port); assertEquals(1,serviceUrls.size()); assertEquals("http://localhost:" + port + "/SpringEndpoint",serviceUrls.get(0)); }

Class: org.apache.cxf.systest.handlers.TrivialSOAPHandlerTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testInvocation() throws Exception { GreeterService service=new GreeterService(); assertNotNull(service); try { Greeter greeter=service.getGreeterPort(); setAddress(greeter,address); String greeting=greeter.greetMe("Bonjour"); assertNotNull("no response received from service",greeting); assertEquals("BONJOUR",greeting); } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

Class: org.apache.cxf.systest.http.ClientServerSessionTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testInvocationWithPerRequestAnnotation() throws Exception { GreeterService service=new GreeterService(); assertNotNull(service); Greeter greeter=service.getGreeterPort(); BindingProvider bp=(BindingProvider)greeter; bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,"http://localhost:" + PORT + "/PerRequest"); bp.getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY,true); String result=greeter.greetMe("World"); assertEquals("Hello World",result); assertEquals("Bonjour default",greeter.sayHi()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testInvocationWithSpringBeanAnnotation() throws Exception { GreeterService service=new GreeterService(); assertNotNull(service); Greeter greeter=service.getGreeterPort(); BindingProvider bp=(BindingProvider)greeter; bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,"http://localhost:" + PORT + "/SpringBean"); bp.getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY,true); String result=greeter.greetMe("World"); assertEquals("Hello World",result); assertEquals("Bonjour World",greeter.sayHi()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testInvocationWithSession() throws Exception { GreeterService service=new GreeterService(); assertNotNull(service); try { Greeter greeter=service.getGreeterPort(); BindingProvider bp=(BindingProvider)greeter; updateAddressPort(bp,PORT); bp.getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY,true); Map> headers=CastUtils.cast((Map)bp.getRequestContext().get("javax.xml.ws.http.request.headers")); if (headers == null) { headers=new HashMap>(); bp.getRequestContext().put("javax.xml.ws.http.request.headers",headers); } List cookies=Arrays.asList(new String[]{"a=a","b=b"}); headers.put("Cookie",cookies); String greeting=greeter.greetMe("Bonjour"); String cookie=""; if (greeting.indexOf(';') != -1) { cookie=greeting.substring(greeting.indexOf(';')); greeting=greeting.substring(0,greeting.indexOf(';')); } assertNotNull("no response received from service",greeting); assertEquals("Hello Bonjour",greeting); assertTrue(cookie.contains("a=a")); assertTrue(cookie.contains("b=b")); greeting=greeter.greetMe("Hello"); cookie=""; if (greeting.indexOf(';') != -1) { cookie=greeting.substring(greeting.indexOf(';')); greeting=greeting.substring(0,greeting.indexOf(';')); } assertNotNull("no response received from service",greeting); assertEquals("Hello Bonjour",greeting); assertTrue(cookie.contains("a=a")); assertTrue(cookie.contains("b=b")); greeting=greeter.greetMe("NiHao"); cookie=""; if (greeting.indexOf(';') != -1) { cookie=greeting.substring(greeting.indexOf(';')); greeting=greeting.substring(0,greeting.indexOf(';')); } assertNotNull("no response received from service",greeting); assertEquals("Hello Hello",greeting); assertTrue(cookie.contains("a=a")); assertTrue(cookie.contains("b=b")); } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testInvocationWithoutSession() throws Exception { GreeterService service=new GreeterService(); assertNotNull(service); try { Greeter greeter=service.getGreeterPort(); updateAddressPort(greeter,PORT); String greeting=greeter.greetMe("Bonjour"); assertNotNull("no response received from service",greeting); assertEquals("Hello Bonjour",greeting); greeting=greeter.greetMe("Hello"); assertNotNull("no response received from service",greeting); assertEquals("Hello Hello",greeting); greeting=greeter.greetMe("NiHao"); assertNotNull("no response received from service",greeting); assertEquals("Hello NiHao",greeting); } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testOnewayInvocationWithSession() throws Exception { GreeterService service=new GreeterService(); assertNotNull(service); try { Greeter greeter=service.getGreeterPort(); BindingProvider bp=(BindingProvider)greeter; updateAddressPort(bp,PORT); bp.getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY,true); greeter.greetMeOneWay("Bonjour"); String greeting=greeter.greetMe("Hello"); if (greeting.indexOf(';') != -1) { greeting=greeting.substring(0,greeting.indexOf(';')); } assertNotNull("no response received from service",greeting); assertEquals("Hello Bonjour",greeting); } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

Class: org.apache.cxf.systest.http.PublishedEndpointUrlTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testPublishedEndpointUrl() throws Exception { Greeter implementor=new org.apache.hello_world_soap_http.GreeterImpl(); String publishedEndpointUrl="http://cxf.apache.org/publishedEndpointUrl"; Bus bus=BusFactory.getDefaultBus(); JaxWsServerFactoryBean svrFactory=new JaxWsServerFactoryBean(); svrFactory.setBus(bus); svrFactory.setServiceClass(Greeter.class); svrFactory.setAddress("http://localhost:" + PORT + "/publishedEndpointUrl"); svrFactory.setPublishedEndpointUrl(publishedEndpointUrl); svrFactory.setServiceBean(implementor); Server server=svrFactory.create(); WSDLReader wsdlReader=WSDLFactory.newInstance().newWSDLReader(); wsdlReader.setFeature("javax.wsdl.verbose",false); URL url=new URL(svrFactory.getAddress() + "?wsdl=1"); HttpURLConnection connect=(HttpURLConnection)url.openConnection(); assertEquals(500,connect.getResponseCode()); Definition wsdl=wsdlReader.readWSDL(svrFactory.getAddress() + "?wsdl"); assertNotNull(wsdl); Collection services=CastUtils.cast(wsdl.getAllServices().values()); final String failMesg="WSDL provided incorrect soap:address location"; for ( Service service : services) { Collection ports=CastUtils.cast(service.getPorts().values()); for ( Port port : ports) { List extensions=port.getExtensibilityElements(); for ( Object extension : extensions) { String actualUrl=null; if (extension instanceof SOAP12Address) { actualUrl=((SOAP12Address)extension).getLocationURI(); } else if (extension instanceof SOAPAddress) { actualUrl=((SOAPAddress)extension).getLocationURI(); } assertEquals(failMesg,publishedEndpointUrl,actualUrl); } } } server.stop(); server.destroy(); bus.shutdown(true); }

Class: org.apache.cxf.systest.http.auth.DigestAuthTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDigestAuth() throws Exception { URL wsdl=getClass().getResource("../greeting.wsdl"); assertNotNull("WSDL is null",wsdl); SOAPService service=new SOAPService(wsdl,serviceName); assertNotNull("Service is null",service); Greeter mortimer=service.getPort(mortimerQ,Greeter.class); assertNotNull("Port is null",mortimer); TestUtil.setAddress(mortimer,"http://localhost:" + PORT + "/digestauth/greeter"); Client client=ClientProxy.getClient(mortimer); HTTPConduit http=(HTTPConduit)client.getConduit(); AuthorizationPolicy authPolicy=new AuthorizationPolicy(); authPolicy.setAuthorizationType("Digest"); authPolicy.setUserName("foo"); authPolicy.setPassword("bar"); http.setAuthorization(authPolicy); String answer=mortimer.sayHi(); assertEquals("Unexpected answer: " + answer,"Hi",answer); }

APIUtilityVerifier UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testNoAuth() throws Exception { URL wsdl=getClass().getResource("../greeting.wsdl"); assertNotNull("WSDL is null",wsdl); SOAPService service=new SOAPService(wsdl,serviceName); assertNotNull("Service is null",service); Greeter mortimer=service.getPort(mortimerQ,Greeter.class); assertNotNull("Port is null",mortimer); TestUtil.setAddress(mortimer,"http://localhost:" + PORT + "/digestauth/greeter"); try { String answer=mortimer.sayHi(); Assert.fail("Unexpected reply (" + answer + "). Should throw exception"); } catch ( Exception e) { Throwable cause=e.getCause(); Assert.assertEquals(HTTPException.class,cause.getClass()); HTTPException he=(HTTPException)cause; Assert.assertEquals(401,he.getResponseCode()); } }

Class: org.apache.cxf.systest.jaxb.MTOMTest

APIUtilityVerifier IterativeVerifier InternalCallVerifier EqualityVerifier 
@Test public void testMTOMInHashMap() throws Exception { Service service=Service.create(new QName("http://foo","bar")); service.addPort(new QName("http://foo","bar"),SOAPBinding.SOAP11HTTP_BINDING,ADDRESS); MTOMService port=service.getPort(new QName("http://foo","bar"),MTOMService.class); final int count=99; ObjectWithHashMapData data=port.getHashMapData(count); for (int y=1; y < count; y++) { byte bytes[]=data.getKeyData().get(Integer.toHexString(y)); assertEquals(y,bytes.length); } }

Class: org.apache.cxf.systest.jaxb.TestServiceTest

InternalCallVerifier EqualityVerifier 
@Test public void testExtraSubClassWithJaxb() throws Throwable { Widget expected=new ExtendedWidget(42,"blah","blah",true,true); TestService testClient=getTestClient(); Widget widgetFromService=testClient.getWidgetById(42); Assert.assertEquals(expected,widgetFromService); }

InternalCallVerifier EqualityVerifier 
@Test public void testExtraSubClassWithJaxbFromEndpoint() throws Throwable { Widget expected=new ExtendedWidget(42,"blah","blah",true,true); TestService testClient=getTestClient(); ((BindingProvider)testClient).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,"http://localhost:" + PORT + "/service/TestEndpoint"); Widget widgetFromService=testClient.getWidgetById(42); Assert.assertEquals(expected,widgetFromService); }

Class: org.apache.cxf.systest.jaxrs.AbstractJAXRSContinuationsTest

InternalCallVerifier EqualityVerifier 
@Test public void testImmediateResumeSubresource() throws Exception { WebClient wc=WebClient.create("http://localhost:" + getPort() + getBaseAddress()+ "/books/subresources/books/resume"); WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(1000000L); wc.accept("text/plain"); String str=wc.get(String.class); assertEquals("immediateResume",str); }

InternalCallVerifier EqualityVerifier 
@Test public void testUnmappedAfterTimeout() throws Exception { WebClient wc=WebClient.create("http://localhost:" + getPort() + getBaseAddress()+ "/books/suspend/unmapped"); Response r=wc.get(); assertEquals(500,r.getStatus()); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetBookNotFound() throws Exception { WebClient wc=WebClient.create("http://localhost:" + getPort() + getBaseAddress()+ "/books/notfound"); wc.accept("text/plain"); Response r=wc.get(); assertEquals(404,r.getStatus()); }

InternalCallVerifier EqualityVerifier 
@Test public void testDefaultTimeout() throws Exception { WebClient wc=WebClient.create("http://localhost:" + getPort() + getBaseAddress()+ "/books/defaulttimeout"); WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(1000000L); Response r=wc.get(); assertEquals(503,r.getStatus()); }

InternalCallVerifier EqualityVerifier 
@Test public void testImmediateResume() throws Exception { WebClient wc=WebClient.create("http://localhost:" + getPort() + getBaseAddress()+ "/books/resume"); WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(1000000L); wc.accept("text/plain"); String str=wc.get(String.class); assertEquals("immediateResume",str); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetBookNotFoundUnmapped() throws Exception { WebClient wc=WebClient.create("http://localhost:" + getPort() + getBaseAddress()+ "/books/notfound/unmapped"); wc.accept("text/plain"); Response r=wc.get(); assertEquals(500,r.getStatus()); }

Class: org.apache.cxf.systest.jaxrs.JAXRS20ClientServerBookTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testPreMatchContainerFilterThrowsException(){ String address="http://localhost:" + PORT + "/throwException"; WebClient wc=WebClient.create(address); Response response=wc.get(); assertEquals(500,response.getStatus()); assertEquals("Prematch filter error",response.readEntity(String.class)); assertEquals("prematch",response.getHeaderString("FilterException")); assertEquals("OK",response.getHeaderString("Response")); assertEquals("OK2",response.getHeaderString("Response2")); assertNull(response.getHeaderString("DynamicResponse")); assertNull(response.getHeaderString("Custom")); assertEquals("serverWrite",response.getHeaderString("ServerWriterInterceptor")); assertEquals("serverWrite2",response.getHeaderString("ServerWriterInterceptor2")); assertEquals("serverWriteHttpResponse",response.getHeaderString("ServerWriterInterceptorHttpResponse")); assertEquals("text/plain;charset=us-ascii",response.getMediaType().toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetBookWebTargetProvider(){ String address="http://localhost:" + PORT + "/bookstore/bookheaders"; Client client=ClientBuilder.newClient(); client.register(new BookInfoReader()); BookInfo book=client.target(address).path("simple").request("application/xml").get(BookInfo.class); assertEquals(124L,book.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookAsyncNoCallback() throws Exception { String address="http://localhost:" + PORT + "/bookstore/bookheaders/simple"; WebClient wc=createWebClient(address); Future future=wc.async().get(Book.class); Book book=future.get(); assertEquals(124L,book.getId()); validateResponse(wc); }

APIUtilityVerifier InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testClientFiltersLocalResponse(){ String address="http://localhost:" + PORT + "/bookstores"; List providers=new ArrayList(); providers.add(new ClientCacheRequestFilter()); providers.add(new ClientHeaderResponseFilter()); WebClient wc=WebClient.create(address,providers); Book theBook=new Book("Echo",123L); Response r=wc.post(theBook); assertEquals(201,r.getStatus()); assertEquals("http://localhost/redirect",r.getHeaderString(HttpHeaders.LOCATION)); Book responseBook=r.readEntity(Book.class); assertSame(theBook,responseBook); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetBookSpec(){ String address="http://localhost:" + PORT + "/bookstore/bookheaders/simple"; Client client=ClientBuilder.newClient(); client.register((Object)ClientFilterClientAndConfigCheck.class); client.property("clientproperty","somevalue"); Book book=client.target(address).request("application/xml").get(Book.class); assertEquals(124L,book.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookSyncLink(){ String address="http://localhost:" + PORT + "/bookstore/bookheaders/simple"; WebClient wc=createWebClient(address); Book book=wc.sync().get(Book.class); assertEquals(124L,book.getId()); validateResponse(wc); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testPostBook(){ String address="http://localhost:" + PORT + "/bookstore/bookheaders/simple"; WebClient wc=createWebClientPost(address); Book book=wc.post(new Book("Book",126L),Book.class); assertEquals(124L,book.getId()); validatePostResponse(wc,false,false); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testPostMatchContainerFilterThrowsException(){ String address="http://localhost:" + PORT + "/bookstore/bookheaders/simple?throwException"; WebClient wc=WebClient.create(address); Response response=wc.get(); assertEquals(500,response.getStatus()); assertEquals("Postmatch filter error",response.readEntity(String.class)); assertEquals("postmatch",response.getHeaderString("FilterException")); assertEquals("OK",response.getHeaderString("Response")); assertEquals("OK2",response.getHeaderString("Response2")); assertEquals("Dynamic",response.getHeaderString("DynamicResponse")); assertEquals("custom",response.getHeaderString("Custom")); assertEquals("serverWrite",response.getHeaderString("ServerWriterInterceptor")); assertEquals("text/plain;charset=us-ascii",response.getMediaType().toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetBookSpecProvider(){ String address="http://localhost:" + PORT + "/bookstore/bookheaders/simple"; Client client=ClientBuilder.newClient(); client.register(new BookInfoReader()); WebTarget target=client.target(address); BookInfo book=target.request("application/xml").get(BookInfo.class); assertEquals(124L,book.getId()); book=target.request("application/xml").get(BookInfo.class); assertEquals(124L,book.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testPostBookAsync() throws Exception { String address="http://localhost:" + PORT + "/bookstore/bookheaders/simple/async"; WebClient wc=createWebClientPost(address); Future future=wc.async().post(Entity.xml(new Book("Book",126L)),Book.class); assertEquals(124L,future.get().getId()); validatePostResponse(wc,true,false); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testReplaceBookMistypedCTAndHttpVerb() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/books2/mistyped"; WebClient wc=WebClient.create(endpointAddress,Collections.singletonList(new ReplaceBodyFilter())); wc.accept("text/mistypedxml").type("text/xml").header("THEMETHOD","PUT"); Book book=wc.invoke("DELETE",new Book("book",555L),Book.class); assertEquals(561L,book.getId()); }

APIUtilityVerifier InternalCallVerifier IdentityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testPostGetCollectionGenericEntityAndType2() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/collections"; WebClient wc=WebClient.create(endpointAddress); wc.accept("application/xml").type("application/xml"); GenericEntity> collectionEntity=createGenericEntity(); GenericType> genericResponseType=new GenericType>(){ } ; Future> future=wc.async().post(Entity.entity(collectionEntity,"application/xml"),genericResponseType); List books2=future.get(); assertNotNull(books2); List books=collectionEntity.getEntity(); assertNotSame(books,books2); assertEquals(2,books2.size()); Book b11=books.get(0); assertEquals(123L,b11.getId()); assertEquals("CXF in Action",b11.getName()); Book b22=books.get(1); assertEquals(124L,b22.getId()); assertEquals("CXF Rocks",b22.getName()); assertEquals(200,wc.getResponse().getStatus()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testPostBookNewMediaType(){ String address="http://localhost:" + PORT + "/bookstore/bookheaders/simple"; WebClient wc=createWebClientPost(address); wc.header("newmediatype","application/v1+xml"); Book book=wc.post(new Book("Book",126L),Book.class); assertEquals(124L,book.getId()); validatePostResponse(wc,false,false); assertEquals("application/v1+xml",wc.getResponse().getHeaderString("newmediatypeused")); }

APIUtilityVerifier InternalCallVerifier IdentityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testPostGetCollectionGenericEntityAndType3() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/collections"; WebClient wc=WebClient.create(endpointAddress); wc.accept("application/xml").type("application/xml"); GenericEntity> collectionEntity=createGenericEntity(); GenericType> genericResponseType=new GenericType>(){ } ; Future future=wc.async().post(Entity.entity(collectionEntity,"application/xml")); Response r=future.get(); List books2=r.readEntity(genericResponseType); assertNotNull(books2); List books=collectionEntity.getEntity(); assertNotSame(books,books2); assertEquals(2,books2.size()); Book b11=books.get(0); assertEquals(123L,b11.getId()); assertEquals("CXF in Action",b11.getName()); Book b22=books.get(1); assertEquals(124L,b22.getId()); assertEquals("CXF Rocks",b22.getName()); assertEquals(200,wc.getResponse().getStatus()); }

APIUtilityVerifier InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testPostCollectionGenericEntityGenericCallback() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/collections3"; WebClient wc=WebClient.create(endpointAddress); wc.accept("application/xml").type("application/xml"); GenericEntity> collectionEntity=createGenericEntity(); final Holder holder=new Holder(); InvocationCallback callback=new GenericInvocationCallback(holder){ } ; Future future=wc.post(collectionEntity,callback); Book book=future.get(); assertEquals(200,wc.getResponse().getStatus()); assertSame(book,holder.value); assertNotSame(collectionEntity.getEntity().get(0),book); assertEquals(collectionEntity.getEntity().get(0).getName(),book.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testPostEmptyBook(){ String address="http://localhost:" + PORT + "/bookstore/bookheaders/simple"; WebClient wc=createWebClientPost(address); WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(1000000); Book book=wc.post(null,Book.class); assertEquals(124L,book.getId()); validatePostResponse(wc,false,true); }

APIUtilityVerifier InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testPostCollectionGenericEntity() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/collections3"; WebClient wc=WebClient.create(endpointAddress); wc.accept("application/xml").type("application/xml"); GenericEntity> collectionEntity=createGenericEntity(); final Holder holder=new Holder(); InvocationCallback callback=createCallback(holder); Future future=wc.post(collectionEntity,callback); Book book=future.get(); assertEquals(200,wc.getResponse().getStatus()); assertSame(book,holder.value); assertNotSame(collectionEntity.getEntity().get(0),book); assertEquals(collectionEntity.getEntity().get(0).getName(),book.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testPostReplaceBook() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/books2"; WebClient wc=WebClient.create(endpointAddress,Collections.singletonList(new ReplaceBodyFilter())); wc.accept("text/xml").type("application/xml"); Book book=wc.post(new Book("book",555L),Book.class); assertEquals(561L,book.getId()); }

APIUtilityVerifier InternalCallVerifier IdentityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testJAXBElementBookCollection() throws Exception { String address="http://localhost:" + PORT + "/bookstore/jaxbelementxmlrootcollections"; Client client=ClientBuilder.newClient(); WebTarget target=client.target(address); Book b1=new Book("CXF in Action",123L); Book b2=new Book("CXF Rocks",124L); List> books=new ArrayList>(); books.add(new JAXBElement(new QName("bookRootElement"),Book.class,b1)); books.add(new JAXBElement(new QName("bookRootElement"),Book.class,b2)); GenericEntity>> collectionEntity=new GenericEntity>>(books){ } ; GenericType>> genericResponseType=new GenericType>>(){ } ; List> books2=target.request().accept("application/xml").post(Entity.entity(collectionEntity,"application/xml"),genericResponseType); assertNotNull(books2); assertNotSame(books,books2); assertEquals(2,books2.size()); Book b11=books.get(0).getValue(); assertEquals(123L,b11.getId()); assertEquals("CXF in Action",b11.getName()); Book b22=books.get(1).getValue(); assertEquals(124L,b22.getId()); assertEquals("CXF Rocks",b22.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testEchoBookElement() throws Exception { BookStore store=JAXRSClientFactory.create("http://localhost:" + PORT,BookStore.class); JAXBElement element=store.echoBookElement(new JAXBElement(new QName("","Book"),Book.class,new Book("CXF",123L))); Book book=element.getValue(); assertEquals(123L,book.getId()); assertEquals("CXF",book.getName()); Book book2=store.echoBookElement(new Book("CXF3",128L)); assertEquals(130L,book2.getId()); assertEquals("CXF3",book2.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testReplaceBookMistypedCTAndHttpVerb2() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/books2/mistyped"; WebClient wc=WebClient.create(endpointAddress,Collections.singletonList(new ReplaceBodyFilter())); wc.accept("text/mistypedxml").header("THEMETHOD","PUT"); Book book=wc.invoke("GET",null,Book.class); assertEquals(561L,book.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testPostReplaceBookMistypedCT() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/books2"; WebClient wc=WebClient.create(endpointAddress,Collections.singletonList(new ReplaceBodyFilter())); wc.accept("text/mistypedxml").type("text/xml"); Book book=wc.post(new Book("book",555L),Book.class); assertEquals(561L,book.getId()); }

APIUtilityVerifier InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testPostCollectionGenericEntityAsEntity() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/collections3"; WebClient wc=WebClient.create(endpointAddress); wc.accept("application/xml"); GenericEntity> collectionEntity=createGenericEntity(); final Holder holder=new Holder(); InvocationCallback callback=createCallback(holder); Future future=wc.async().post(Entity.entity(collectionEntity,"application/xml"),callback); Book book=future.get(); assertEquals(200,wc.getResponse().getStatus()); assertSame(book,holder.value); assertNotSame(collectionEntity.getEntity().get(0),book); assertEquals(collectionEntity.getEntity().get(0).getName(),book.getName()); }

Class: org.apache.cxf.systest.jaxrs.JAXRSAsyncClientTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testPatchBook() throws Exception { String address="http://localhost:" + PORT + "/bookstore/patch"; WebClient wc=WebClient.create(address); wc.type("application/xml"); WebClient.getConfig(wc).getRequestContext().put("use.async.http.conduit",true); Book book=wc.invoke("PATCH",new Book("Patch",123L),Book.class); assertEquals("Patch",book.getName()); wc.close(); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testRetrieveBookCustomMethodAsync() throws Exception { String address="http://localhost:" + PORT + "/bookstore/retrieve"; WebClient wc=WebClient.create(address); wc.accept("application/xml"); Future book=wc.async().method("RETRIEVE",Entity.xml(new Book("Retrieve",123L)),Book.class); assertEquals("Retrieve",book.get().getName()); wc.close(); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testRetrieveBookCustomMethodAsyncSync() throws Exception { String address="http://localhost:" + PORT + "/bookstore/retrieve"; WebClient wc=WebClient.create(address); wc.type("application/xml").accept("application/xml"); Book book=wc.invoke("RETRIEVE",new Book("Retrieve",123L),Book.class); assertEquals("Retrieve",book.getName()); wc.close(); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testDeleteWithBody() throws Exception { String address="http://localhost:" + PORT + "/bookstore/deletebody"; WebClient wc=WebClient.create(address); wc.type("application/xml").accept("application/xml"); WebClient.getConfig(wc).getRequestContext().put("use.async.http.conduit",true); Book book=wc.invoke("DELETE",new Book("Delete",123L),Book.class); assertEquals("Delete",book.getName()); wc.close(); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookAsyncResponse404() throws Exception { String address="http://localhost:" + PORT + "/bookstore/bookheaders/404"; WebClient wc=createWebClient(address); Future future=wc.async().get(Response.class); assertEquals(404,future.get().getStatus()); wc.close(); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testPatchBookInputStream() throws Exception { String address="http://localhost:" + PORT + "/bookstore/patch"; WebClient wc=WebClient.create(address); wc.type("application/xml"); WebClient.getConfig(wc).getRequestContext().put("use.async.http.conduit",true); Book book=wc.invoke("PATCH",new ByteArrayInputStream("Patch123".getBytes()),Book.class); assertEquals("Patch",book.getName()); wc.close(); }

Class: org.apache.cxf.systest.jaxrs.JAXRSAtomBookTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBooks2() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/sub/"; Feed feed=getFeed(endpointAddress,null); assertEquals("http://localhost:" + PORT + "/bookstore/sub/",feed.getBaseUri().toString()); assertEquals("Collection of Books",feed.getTitle()); getAndCompareJson("http://localhost:" + PORT + "/bookstore/sub/books/entries/123.json","resources/expected_atom_book_json2.txt","*/*"); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBooks() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/bookstore/books/feed"; Feed feed=getFeed(endpointAddress,null); assertEquals("http://localhost:" + PORT + "/bookstore/bookstore/books/feed",feed.getBaseUri().toString()); assertEquals("Collection of Books",feed.getTitle()); getAndCompareJson("http://localhost:" + PORT + "/bookstore/bookstore/books/feed","resources/expected_atom_books_json.txt","application/json"); getAndCompareJson("http://localhost:" + PORT + "/bookstore/bookstore/books/jsonfeed","resources/expected_atom_books_jsonfeed.txt","application/json, text/html, application/xml;q=0.9," + " application/xhtml+xml, image/png, image/jpeg, image/gif," + " image/x-xbitmap, */*;q=0.1"); Entry entry=addEntry(endpointAddress); entry=addEntry(endpointAddress + "/relative"); endpointAddress="http://localhost:" + PORT + "/bookstore/bookstore/books/subresources/123"; entry=getEntry(endpointAddress,null); assertEquals("CXF in Action",entry.getTitle()); getAndCompareJson("http://localhost:" + PORT + "/bookstore/bookstore/books/entries/123","resources/expected_atom_book_json.txt","application/json"); getAndCompareJson("http://localhost:" + PORT + "/bookstore/bookstore/books/entries/123?_type="+ "application/json","resources/expected_atom_book_json.txt","*/*"); getAndCompareJson("http://localhost:" + PORT + "/bookstore/bookstore/books/entries/123?_type="+ "json","resources/expected_atom_book_json.txt","*/*"); getAndCompareJson("http://localhost:" + PORT + "/bookstore/bookstore/books/entries/123.json","resources/expected_atom_book_json.txt","*/*"); getAndCompareJson("http://localhost:" + PORT + "/bookstore/bookstore/books/entries/123.json;a=b","resources/expected_atom_book_json_matrix.txt","*/*"); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBooksWithCustomProvider() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/bookstore4/books/feed"; Feed feed=getFeed(endpointAddress,null); assertEquals("http://localhost:" + PORT + "/bookstore/bookstore4/books/feed",feed.getBaseUri().toString()); assertEquals("Collection of Books",feed.getTitle()); }

Class: org.apache.cxf.systest.jaxrs.JAXRSClientServerBookTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testPostAnd401WithText() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/post401"; WebClient wc=WebClient.create(endpointAddress); WebClient.getConfig(wc).getHttpConduit().getClient().setAllowChunking(false); Response r=wc.post(null); assertEquals(401,r.getStatus()); assertEquals("This is 401",getStringFromInputStream((InputStream)r.getEntity())); }

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testServerWebApplicationException() throws Exception { WebClient wc=WebClient.create("http://localhost:" + PORT + "/bookstore/webappexception"); wc.accept("application/xml"); try { wc.get(Book.class); fail("Exception expected"); } catch ( ServerErrorException ex) { assertEquals(500,ex.getResponse().getStatus()); assertEquals("This is a WebApplicationException",ex.getResponse().readEntity(String.class)); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookRoot() throws Exception { String address="http://localhost:" + PORT + "/bookstore/;JSESSIONID=xxx"; WebClient wc=WebClient.create(address); Book book=wc.get(Book.class); assertEquals(124L,book.getId()); assertEquals("root",book.getName()); }

InternalCallVerifier EqualityVerifier 
@Test public void testBookWithSpace() throws Exception { WebClient client=WebClient.create("http://localhost:" + PORT + "/bookstore/").path("the books/123"); Book book=client.get(Book.class); assertEquals(123L,book.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testAddBookCustomFailureStatus() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/books/customstatus"; WebClient client=WebClient.create(endpointAddress); Book book=client.type("text/xml").accept("application/xml").post(new Book(),Book.class); assertEquals(888L,book.getId()); Response r=client.getResponse(); assertEquals("CustomValue",r.getMetadata().getFirst("CustomHeader")); assertEquals(233,r.getStatus()); assertEquals("application/xml",r.getMetadata().getFirst("Content-Type")); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testEmptyPost() throws Exception { WebClient wc=WebClient.create("http://localhost:" + PORT + "/bookstore/emptypost"); Response response=wc.post(null); assertEquals(204,response.getStatus()); assertNull(response.getMetadata().getFirst("Content-Type")); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testUseMapperOnBus(){ String address="http://localhost:" + PORT + "/bookstore/mapperonbus"; WebClient wc=WebClient.create(address); Response r=wc.post(null); assertEquals(500,r.getStatus()); MediaType mt=r.getMediaType(); assertEquals("text/plain;charset=utf-8",mt.toString().toLowerCase()); assertEquals("the-mapper",r.getHeaderString("BusMapper")); assertEquals("BusMapperException",r.readEntity(String.class)); }

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testServerWebApplicationExceptionXML() throws Exception { WebClient wc=WebClient.create("http://localhost:" + PORT + "/bookstore/webappexceptionXML"); wc.accept("application/xml"); try { wc.get(Book.class); fail("Exception expected"); } catch ( NotAcceptableException ex) { assertEquals(406,ex.getResponse().getStatus()); Book exBook=ex.getResponse().readEntity(Book.class); assertEquals("Exception",exBook.getName()); assertEquals(999L,exBook.getId()); } }

APIUtilityVerifier IterativeVerifier InternalCallVerifier EqualityVerifier 
@Test public void testBadlyQuotedHeaders() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/badlyquotedheaders"; String[] responses=new String[]{"\"some text","\"some text, some more text with inlined \"","\"some te\\"}; for (int i=0; i < 3; i++) { WebClient wc=WebClient.create(endpointAddress); WebClient.getConfig(wc).getRequestContext().put("org.apache.cxf.http.header.split",true); Response r=wc.query("type",Integer.toString(i)).get(); assertEquals(responses[i],r.getMetadata().get("SomeHeader" + i).get(0)); } WebClient wc=WebClient.create(endpointAddress); WebClient.getConfig(wc).getRequestContext().put("org.apache.cxf.http.header.split",true); Response r3=wc.query("type","3").get(); List r3values=r3.getMetadata().get("SomeHeader3"); assertEquals(4,r3values.size()); assertEquals("some text",r3values.get(0)); assertEquals("\"other quoted\"",r3values.get(1)); assertEquals("text",r3values.get(2)); assertEquals("blah",r3values.get(3)); }

InternalCallVerifier EqualityVerifier 
@Test public void testUpdateBook() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/books"; File input=new File(getClass().getResource("resources/update_book.txt").toURI()); PutMethod put=new PutMethod(endpointAddress); RequestEntity entity=new FileRequestEntity(input,"text/xml; charset=ISO-8859-1"); put.setRequestEntity(entity); HttpClient httpclient=new HttpClient(); try { int result=httpclient.executeMethod(put); assertEquals(200,result); InputStream expected=getClass().getResourceAsStream("resources/expected_update_book.txt"); assertEquals(stripXmlInstructionIfNeeded(getStringFromInputStream(expected)),stripXmlInstructionIfNeeded(getStringFromInputStream(put.getResponseBodyAsStream()))); } finally { put.releaseConnection(); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testUpdateBookWithProxy() throws Exception { String address="http://localhost:" + PORT; BookStore store=JAXRSClientFactory.create(address,BookStore.class); Book b=store.updateEchoBook(new Book("CXF",125L)); assertEquals(125L,b.getId()); }

APIUtilityVerifier InternalCallVerifier IdentityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testPostCollectionOfBooksWebClient() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/collections"; WebClient wc=WebClient.create(endpointAddress); wc.accept("application/xml").type("application/xml"); Book b1=new Book("CXF in Action",123L); Book b2=new Book("CXF Rocks",124L); List books=new ArrayList(); books.add(b1); books.add(b2); List books2=new ArrayList(wc.postAndGetCollection(books,Book.class,Book.class)); assertNotNull(books2); assertNotSame(books,books2); assertEquals(2,books2.size()); Book b11=books.get(0); assertEquals(123L,b11.getId()); assertEquals("CXF in Action",b11.getName()); Book b22=books.get(1); assertEquals(124L,b22.getId()); assertEquals("CXF Rocks",b22.getName()); assertEquals(200,wc.getResponse().getStatus()); }

InternalCallVerifier EqualityVerifier 
@SuppressWarnings("deprecation") @Test public void testGetPlainLong() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/booksplain"; PostMethod post=new PostMethod(endpointAddress); post.addRequestHeader("Content-Type","text/plain"); post.addRequestHeader("Accept","text/plain"); post.setRequestBody("12345"); HttpClient httpclient=new HttpClient(); try { int result=httpclient.executeMethod(post); assertEquals(200,result); assertEquals(post.getResponseBodyAsString(),"12345"); } finally { post.releaseConnection(); } }

InternalCallVerifier EqualityVerifier 
@Test public void testEmptyPostProxy() throws Exception { BookStore store=JAXRSClientFactory.create("http://localhost:" + PORT,BookStore.class); store.emptypost(); assertEquals(204,WebClient.client(store).getResponse().getStatus()); }

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testServerWebApplicationExceptionWithProxy() throws Exception { BookStore store=JAXRSClientFactory.create("http://localhost:" + PORT,BookStore.class); try { store.throwException(); fail("Exception expected"); } catch ( ServerErrorException ex) { assertEquals(500,ex.getResponse().getStatus()); assertEquals("This is a WebApplicationException",ex.getResponse().readEntity(String.class)); } }

InternalCallVerifier EqualityVerifier 
@Test public void testProxyBeanParam() throws Exception { BookStore store=JAXRSClientFactory.create("http://localhost:" + PORT,BookStore.class); BookStore.BookBean bean=new BookStore.BookBean(); bean.setId(100L); bean.setId2(23L); BookStore.BookBeanNested nested=new BookStore.BookBeanNested(); nested.setId4(123); bean.setNested(nested); Book book=store.getBeanParamBook(bean); assertEquals(123L,book.getId()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testEmptyPostBytes() throws Exception { WebClient wc=WebClient.create("http://localhost:" + PORT + "/bookstore/emptypost"); Response response=wc.post(new byte[]{}); assertEquals(204,response.getStatus()); assertNull(response.getMetadata().getFirst("Content-Type")); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetHeadBook123WebClient2() throws Exception { String address="http://localhost:" + PORT + "/bookstore/getheadbook/"; WebClient client=WebClient.create(address); Book b=client.get(Book.class); assertEquals(b.getId(),123L); }

EqualityVerifier 
@Test public void testAddBookEmptyContent() throws Exception { Response r=WebClient.create("http://localhost:" + PORT + "/bookstore/books").type("*/*").post(null); assertEquals(400,r.getStatus()); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testRetrieveBookCustomMethodReflection() throws Exception { try { doRetrieveBook(false); fail("HTTPUrlConnection does not support custom verbs without the reflection"); } catch ( ProcessingException ex) { } Book book=doRetrieveBook(true); assertEquals("Retrieve",book.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testCapturedServerInFault() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/infault"; WebClient wc=WebClient.create(endpointAddress); Response r=wc.get(); assertEquals(401,r.getStatus()); }

APIUtilityVerifier InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testPostCollectionGenericEntityWebClient() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/collections3"; WebClient wc=WebClient.create(endpointAddress); wc.accept("application/xml").type("application/xml"); Book b1=new Book("CXF in Action",123L); Book b2=new Book("CXF Rocks",124L); List books=new ArrayList(); books.add(b1); books.add(b2); GenericEntity> genericCollectionEntity=new GenericEntity>(books){ } ; Book book=wc.post(genericCollectionEntity,Book.class); assertEquals(200,wc.getResponse().getStatus()); assertNotSame(b1,book); assertEquals(b1.getName(),book.getName()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testBookWithSpaceProxyWithBufferedStream() throws Exception { BookStore store=JAXRSClientFactory.create("http://localhost:" + PORT,BookStore.class); WebClient.getConfig(store).getResponseContext().put("buffer.proxy.response","true"); Book book=store.getBookWithSpace("123"); assertEquals(123L,book.getId()); assertTrue(WebClient.client(store).getResponse().readEntity(String.class).contains("

InternalCallVerifier EqualityVerifier 
@Test public void testOnewayProxy() throws Exception { BookStore proxy=JAXRSClientFactory.create("http://localhost:" + PORT,BookStore.class); proxy.onewayRequest(); assertEquals(202,WebClient.client(proxy).getResponse().getStatus()); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testBookWithMultipleExceptions() throws Exception { List providers=new LinkedList(); providers.add(new BookServer.NotReturnedExceptionMapper()); providers.add(new BookServer.NotFoundExceptionMapper()); BookStore store=JAXRSClientFactory.create("http://localhost:" + PORT,BookStore.class,providers); try { store.getBookWithExceptions(true); fail(); } catch ( BookNotReturnedException ex) { assertEquals("notReturned",ex.getMessage()); } try { store.getBookWithExceptions(false); fail(); } catch ( BookNotFoundFault ex) { assertEquals("notFound",ex.getMessage()); } }

InternalCallVerifier EqualityVerifier 
@Test public void testGetBookAdapterInfoProxy() throws Exception { BookStore store=JAXRSClientFactory.create("http://localhost:" + PORT,BookStore.class); BookInfo info=store.getBookAdapter(); assertEquals(123L,info.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetCustomBookText(){ String address="http://localhost:" + PORT + "/bookstore/customtext"; WebClient wc=WebClient.create(address); Response r=wc.accept("text/custom").get(); String name=r.readEntity(String.class); assertEquals("Good book",name); assertEquals("text/custom;charset=us-ascii",r.getMediaType().toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testProxyBeanParam2() throws Exception { BookStore store=JAXRSClientFactory.create("http://localhost:" + PORT,BookStore.class); WebClient.getConfig(store).getHttpConduit().getClient().setReceiveTimeout(10000000L); BookStore.BookBean2 bean=new BookStore.BookBean2(); bean.setId(100L); bean.setId2(23L); BookStore.BookBeanNested nested=new BookStore.BookBeanNested(); nested.setId4(123); Book book=store.getTwoBeanParamsBook(bean,nested); assertEquals(123L,book.getId()); }

InternalCallVerifier IdentityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetBookArray() throws Exception { BookStore store=JAXRSClientFactory.create("http://localhost:" + PORT,BookStore.class); Book b1=new Book("CXF in Action",123L); Book b2=new Book("CXF Rocks",124L); Book[] books=new Book[2]; books[0]=b1; books[1]=b2; Book[] books2=store.getBookArray(books); assertNotNull(books2); assertNotSame(books,books2); assertEquals(2,books2.length); Book b11=books2[0]; assertEquals(123L,b11.getId()); assertEquals("CXF in Action",b11.getName()); Book b22=books2[1]; assertEquals(124L,b22.getId()); assertEquals("CXF Rocks",b22.getName()); }

InternalCallVerifier EqualityVerifier 
@Test public void testCreatePutWithProxy() throws Exception { BookStore bs=JAXRSClientFactory.create("http://localhost:" + PORT,BookStore.class); Response r=bs.createBook(777L); assertEquals(200,r.getStatus()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testBlockAndTrowException() throws Exception { String address="http://localhost:" + PORT + "/bookstore/blockAndThrowException"; WebClient wc=WebClient.create(address); Response r=wc.get(); assertEquals(500,r.getStatus()); }

InternalCallVerifier EqualityVerifier 
@Test public void testProxyWithCollectionMatrixParams() throws Exception { BookStore proxy=JAXRSClientFactory.create("http://localhost:" + PORT,BookStore.class); List params=new ArrayList(); params.add("12"); params.add("3"); Book book=proxy.getBookByMatrixListParams(params); assertEquals(123L,book.getId()); }

InternalCallVerifier EqualityVerifier 
@Test public void testEchoBookName202() throws Exception { WebClient wc=WebClient.create("http://localhost:" + PORT + "/bookstore/booksecho202"); wc.type("text/plain").accept("text/plain"); Response r=wc.post("book"); assertEquals(202,r.getStatus()); assertEquals("book",r.readEntity(String.class)); }

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testServerWebApplicationExceptionResponse() throws Exception { WebClient wc=WebClient.create("http://localhost:" + PORT + "/bookstore/webappexception"); wc.accept("application/xml"); try { Response r=wc.get(Response.class); assertEquals(500,r.getStatus()); } catch ( WebApplicationException ex) { fail("Unexpected exception"); } }

APIUtilityVerifier InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testPostCollectionGetBooksWebClient() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/collections3"; WebClient wc=WebClient.create(endpointAddress); wc.accept("application/xml").type("application/xml"); Book b1=new Book("CXF in Action",123L); Book b2=new Book("CXF Rocks",124L); List books=new ArrayList(); books.add(b1); books.add(b2); Book book=wc.postCollection(books,Book.class,Book.class); assertEquals(200,wc.getResponse().getStatus()); assertNotSame(b1,book); assertEquals(b1.getName(),book.getName()); }

InternalCallVerifier EqualityVerifier 
@Test public void testConsumeTypeMismatch() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/unsupportedcontenttype"; PostMethod post=new PostMethod(endpointAddress); post.setRequestHeader("Content-Type","application/bar"); post.setRequestHeader("Accept","text/xml"); HttpClient httpclient=new HttpClient(); try { int result=httpclient.executeMethod(post); assertEquals(415,result); } finally { post.releaseConnection(); } }

EqualityVerifier 
@Test public void testAddBookEmptyContentWithNullable() throws Exception { Book defaultBook=WebClient.create("http://localhost:" + PORT + "/bookstore/books/null").type("*/*").post(null,Book.class); assertEquals("Default Book",defaultBook.getName()); }

InternalCallVerifier EqualityVerifier 
@SuppressWarnings("deprecation") @Test public void testNoMessageReaderFound() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/binarybooks"; PostMethod post=new PostMethod(endpointAddress); post.setRequestHeader("Content-Type","application/octet-stream"); post.setRequestHeader("Accept","text/xml"); post.setRequestBody("Bar"); HttpClient httpclient=new HttpClient(); try { int result=httpclient.executeMethod(post); assertEquals(415,result); } finally { post.releaseConnection(); } }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testOnewayWebClient() throws Exception { WebClient client=WebClient.create("http://localhost:" + PORT + "/bookstore/oneway"); Response r=client.header("OnewayRequest","true").post(null); assertEquals(202,r.getStatus()); assertFalse(r.getHeaders().isEmpty()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookWithColonMarks() throws Exception { String endpointAddressUrlEncoded="http://localhost:" + PORT + "/bookstore/books/colon/"+ URLEncoder.encode("1:2:3",StandardCharsets.UTF_8.name()); Response r=WebClient.create(endpointAddressUrlEncoded).get(); assertEquals(404,r.getStatus()); String endpointAddress="http://localhost:" + PORT + "/bookstore/books/colon/1:2:3"; WebClient wc=WebClient.create(endpointAddress); Book b=wc.get(Book.class); assertEquals(123L,b.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookByHeaderPerRequestConstructorFault() throws Exception { String address="http://localhost:" + PORT + "/bookstore2/bookheaders"; WebClient wc=WebClient.create(address); wc.accept("application/xml"); wc.header("BOOK","1","2","4"); Response r=wc.get(); assertEquals(400,r.getStatus()); assertEquals("Constructor: Header value 3 is required",r.readEntity(String.class)); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testBookWithExceptionsNoMapper() throws Exception { BookStore store=JAXRSClientFactory.create("http://localhost:" + PORT,BookStore.class); try { store.getBookWithExceptions(true); fail(); } catch ( WebApplicationException ex) { assertEquals("notReturned",ex.getResponse().getHeaderString("Status")); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookQueryDefault() throws Exception { String address="http://localhost:" + PORT + "/bookstore/books/query/default"; WebClient wc=WebClient.create(address); Response r=wc.get(); Book book=r.readEntity(Book.class); assertEquals(123L,book.getId()); }

InternalCallVerifier EqualityVerifier 
@Test public void testUpdateBookFailed() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/books"; File input=new File(getClass().getResource("resources/update_book_not_exist.txt").toURI()); PutMethod post=new PutMethod(endpointAddress); RequestEntity entity=new FileRequestEntity(input,"text/xml; charset=ISO-8859-1"); post.setRequestEntity(entity); HttpClient httpclient=new HttpClient(); try { int result=httpclient.executeMethod(post); assertEquals(304,result); } finally { post.releaseConnection(); } }

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testServerWebApplicationExceptionXMLWithProxy() throws Exception { BookStore proxy=JAXRSClientFactory.create("http://localhost:" + PORT,BookStore.class); try { proxy.throwExceptionXML(); fail("Exception expected"); } catch ( NotAcceptableException ex) { assertEquals(406,ex.getResponse().getStatus()); Book exBook=ex.getResponse().readEntity(Book.class); assertEquals("Exception",exBook.getName()); assertEquals(999L,exBook.getId()); } }

InternalCallVerifier EqualityVerifier 
@Test public void testWithComplexPath(){ WebClient wc=WebClient.create("http://localhost:" + PORT + "/bookstore/allCharsButA-B/:@!$&'()*+,;=-._~"); wc.accept("application/xml"); Book book=wc.get(Book.class); assertEquals("Encoded Path",book.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testStatusAngHeadersFromStream() throws Exception { String address="http://localhost:" + PORT + "/bookstore/books/statusFromStream"; WebClient wc=WebClient.create(address); wc.accept("text/xml"); Response r=wc.get(); assertEquals(503,r.getStatus()); assertEquals("text/custom+plain",r.getMediaType().toString()); assertEquals("CustomValue",r.getHeaderString("CustomHeader")); assertEquals("Response is not available",r.readEntity(String.class)); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetStringList() throws Exception { String address="http://localhost:" + PORT; JAXRSClientFactoryBean bean=new JAXRSClientFactoryBean(); bean.setProvider(new BookStore.StringListBodyReaderWriter()); bean.setAddress(address); bean.setResourceClass(BookStore.class); BookStore store=bean.create(BookStore.class); List str=store.getBookListArray(); assertEquals("Good book",str.get(0)); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetPrimitiveIntArray() throws Exception { String address="http://localhost:" + PORT; JAXRSClientFactoryBean bean=new JAXRSClientFactoryBean(); bean.setProvider(new BookStore.PrimitiveIntArrayReaderWriter()); bean.setAddress(address); bean.setResourceClass(BookStore.class); BookStore store=bean.create(BookStore.class); int[] arr=store.getBookIndexAsIntArray(); assertEquals(3,arr.length); assertEquals(1,arr[0]); assertEquals(2,arr[1]); assertEquals(3,arr[2]); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testEchoXmlBookQuery() throws Exception { String address="http://localhost:" + PORT; BookStore store=JAXRSClientFactory.create(address,BookStore.class,Collections.singletonList(new BookServer.ParamConverterImpl())); Book b=store.echoXmlBookQuery(new Book("query",125L),(byte)125); assertEquals(125L,b.getId()); assertEquals("query",b.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetSearchBookSQL() throws Exception { String address="http://localhost:" + PORT + "/bookstore/books/querycontext/id=ge=123"; WebClient client=WebClient.create(address); client.accept("text/plain"); String sql=client.get(String.class); assertEquals("SELECT * FROM books WHERE id >= '123'",sql); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetCollectionOfBooks() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/collections"; WebClient wc=WebClient.create(endpointAddress); wc.accept("application/xml"); Collection collection=wc.getCollection(Book.class); assertEquals(1,collection.size()); Book book=collection.iterator().next(); assertEquals(123L,book.getId()); }

APIUtilityVerifier InternalCallVerifier IdentityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetBookCollection() throws Exception { BookStore store=JAXRSClientFactory.create("http://localhost:" + PORT,BookStore.class); Book b1=new Book("CXF in Action",123L); Book b2=new Book("CXF Rocks",124L); List books=new ArrayList(); books.add(b1); books.add(b2); List books2=store.getBookCollection(books); assertNotNull(books2); assertNotSame(books,books2); assertEquals(2,books2.size()); Book b11=books2.get(0); assertEquals(123L,b11.getId()); assertEquals("CXF in Action",b11.getName()); Book b22=books2.get(1); assertEquals(124L,b22.getId()); assertEquals("CXF Rocks",b22.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookSameUriAutoRedirect() throws Exception { String address="http://localhost:" + PORT + "/bookstore/redirect?sameuri=true"; WebClient wc=WebClient.create(address); WebClient.getConfig(wc).getHttpConduit().getClient().setAutoRedirect(true); WebClient.getConfig(wc).getRequestContext().put(org.apache.cxf.message.Message.MAINTAIN_SESSION,Boolean.TRUE); Response r=wc.get(); Book book=r.readEntity(Book.class); assertEquals(123L,book.getId()); String requestUri=r.getStringHeaders().getFirst("RequestURI"); assertEquals("http://localhost:" + PORT + "/bookstore/redirect?redirect=true",requestUri); String theCookie=r.getStringHeaders().getFirst("TheCookie"); assertEquals("b",theCookie); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetPrimitiveDoubleArray() throws Exception { String address="http://localhost:" + PORT; JAXRSClientFactoryBean bean=new JAXRSClientFactoryBean(); bean.setProvider(new BookStore.PrimitiveDoubleArrayReaderWriter()); bean.setAddress(address); bean.setResourceClass(BookStore.class); BookStore store=bean.create(BookStore.class); double[] arr=store.getBookIndexAsDoubleArray(); assertEquals(3,arr.length); assertEquals(1,arr[0],0.0); assertEquals(2,arr[1],0.0); assertEquals(3,arr[2],0.0); }

InternalCallVerifier EqualityVerifier 
@Test public void testEchoBookElementWebClient() throws Exception { WebClient wc=WebClient.create("http://localhost:" + PORT + "/bookstore/books/element/echo"); wc.type("application/xml").accept("application/xml"); Book book=wc.post(new Book("CXF",123L),Book.class); assertEquals(123L,book.getId()); assertEquals("CXF",book.getName()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testTempRedirectWebClient() throws Exception { WebClient client=WebClient.create("http://localhost:" + PORT + "/bookstore/tempredirect"); Response r=client.type("*/*").get(); assertEquals(307,r.getStatus()); MultivaluedMap map=r.getMetadata(); assertEquals("http://localhost:" + PORT + "/whatever/redirection?css1=http%3A//bar",map.getFirst("Location").toString()); List cookies=r.getMetadata().get("Set-Cookie"); assertNotNull(cookies); assertEquals(2,cookies.size()); }

InternalCallVerifier EqualityVerifier 
@Test public void testDeleteWithProxy() throws Exception { BookStore bs=JAXRSClientFactory.create("http://localhost:" + PORT,BookStore.class); Response r=bs.deleteBook("123"); assertEquals(200,r.getStatus()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testWebClientUnwrapBookWithXslt() throws Exception { XSLTJaxbProvider provider=new XSLTJaxbProvider(); provider.setInTemplate("classpath:/org/apache/cxf/systest/jaxrs/resources/unwrapbook.xsl"); WebClient wc=WebClient.create("http://localhost:" + PORT + "/bookstore/books/wrapper",Collections.singletonList(provider)); wc.path("{id}",123); Book book=wc.get(Book.class); assertNotNull(book); assertEquals(123L,book.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testPostNullGetEmptyCollectionProxy() throws Exception { String endpointAddress="http://localhost:" + PORT; BookStore bs=JAXRSClientFactory.create(endpointAddress,BookStore.class); List books=bs.postBookGetCollection(null); assertNotNull(books); assertEquals(0,books.size()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testPostObjectGetCollection() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/collectionBook"; WebClient wc=WebClient.create(endpointAddress); wc.accept("application/xml").type("application/xml"); Book b1=new Book("Book",666L); List books=new ArrayList(wc.postObjectGetCollection(b1,Book.class)); assertNotNull(books); assertEquals(1,books.size()); Book b=books.get(0); assertEquals(666L,b.getId()); assertEquals("Book",b.getName()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testHeadBookByURL() throws Exception { WebClient wc=WebClient.create("http://localhost:" + PORT + "/bookstore/bookurl/http%3A%2F%2Ftest.com%2Frss%2F123"); Response response=wc.head(); assertTrue(response.getMetadata().size() != 0); assertEquals(0,((InputStream)response.getEntity()).available()); }

InternalCallVerifier EqualityVerifier 
@Test public void testDeleteBook() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/books/123"; DeleteMethod post=new DeleteMethod(endpointAddress); HttpClient httpclient=new HttpClient(); try { int result=httpclient.executeMethod(post); assertEquals(200,result); } finally { post.releaseConnection(); } }

InternalCallVerifier EqualityVerifier 
@Test public void testMalformedAcceptType(){ WebClient wc=WebClient.create("http://localhost:" + PORT + "/bookstore/books/123"); wc.accept("application"); Response r=wc.get(); assertEquals(406,r.getStatus()); }

InternalCallVerifier EqualityVerifier 
@Test public void testEmptyPostProxy2() throws Exception { String address="http://localhost:" + PORT; JAXRSClientFactoryBean bean=new JAXRSClientFactoryBean(); bean.setAddress(address); bean.setResourceClass(BookStore.class); BookStore store=bean.create(BookStore.class); store.emptypostNoPath(); assertEquals(204,WebClient.client(store).getResponse().getStatus()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testSearchBook123WithWebClient() throws Exception { String address="http://localhost:" + PORT + "/bookstore/books/search"; WebClient client=WebClient.create(address); Book b=client.query("_s","name==CXF*;id=ge=123;id=lt=124").get(Book.class); assertEquals(b.getId(),123L); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookWithNameInQuery() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/name-in-query"; WebClient wc=WebClient.create(endpointAddress); String name="Many spaces"; wc.query("name",name); Book b=wc.get(Book.class); assertEquals(name,b.getName()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testGetCDs() throws Exception { WebClient wc=WebClient.create("http://localhost:" + PORT + "/bookstore/cds"); CDs cds=wc.get(CDs.class); Collection collection=cds.getCD(); assertEquals(2,collection.size()); assertTrue(collection.contains(new CD("BICYCLE RACE",124))); assertTrue(collection.contains(new CD("BOHEMIAN RHAPSODY",123))); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetCustomBookResponse(){ String address="http://localhost:" + PORT + "/bookstore/customresponse"; WebClient wc=WebClient.create(address); Response r=wc.accept("application/xml").get(Response.class); Book book=r.readEntity(Book.class); assertEquals(222L,book.getId()); assertEquals("OK",r.getHeaderString("customresponse")); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testUpdateBookWithDom() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/bookswithdom"; File input=new File(getClass().getResource("resources/update_book.txt").toURI()); PutMethod put=new PutMethod(endpointAddress); RequestEntity entity=new FileRequestEntity(input,"text/xml; charset=ISO-8859-1"); put.setRequestEntity(entity); HttpClient httpclient=new HttpClient(); try { int result=httpclient.executeMethod(put); assertEquals(200,result); String resp=put.getResponseBodyAsString(); InputStream expected=getClass().getResourceAsStream("resources/update_book.txt"); String s=getStringFromInputStream(expected); assertTrue(resp.indexOf(s) >= 0); } finally { put.releaseConnection(); } }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testGetCustomBookBufferedResponse(){ String address="http://localhost:" + PORT + "/bookstore/customresponse"; WebClient wc=WebClient.create(address); Response r=wc.accept("application/xml").get(Response.class); r.bufferEntity(); String bookStr=r.readEntity(String.class); assertTrue(bookStr.endsWith("")); Book book=r.readEntity(Book.class); assertEquals(222L,book.getId()); assertEquals("OK",r.getHeaderString("customresponse")); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAddBookProxyResponse(){ BookStore store=JAXRSClientFactory.create("http://localhost:" + PORT,BookStore.class); Book b=new Book("CXF rocks",123L); Response r=store.addBook(b); assertNotNull(r); InputStream is=(InputStream)r.getEntity(); assertNotNull(is); XMLSource source=new XMLSource(is); source.setBuffering(); assertEquals(124L,Long.parseLong(source.getValue("Book/id"))); assertEquals("CXF rocks",source.getValue("Book/name")); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookFromResponseWithWebClientAndReader() throws Exception { String address="http://localhost:" + PORT + "/bookstore/genericresponse/123"; WebClient wc=WebClient.create(address); Response r=wc.accept("application/xml").get(); assertEquals(200,r.getStatus()); Book book=r.readEntity(Book.class); assertEquals(123L,book.getId()); }

InternalCallVerifier EqualityVerifier 
@Test public void testEmptyPutProxy() throws Exception { BookStore store=JAXRSClientFactory.create("http://localhost:" + PORT,BookStore.class); store.emptyput(); assertEquals(204,WebClient.client(store).getResponse().getStatus()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testEchoBookElementWildcard() throws Exception { BookStore store=JAXRSClientFactory.create("http://localhost:" + PORT,BookStore.class); JAXBElement element=store.echoBookElementWildcard(new JAXBElement(new QName("","Book"),Book.class,new Book("CXF",123L))); Book book=(Book)element.getValue(); assertEquals(123L,book.getId()); assertEquals("CXF",book.getName()); }

InternalCallVerifier EqualityVerifier 
@Test public void testUpdateWithProxy() throws Exception { BookStore bs=JAXRSClientFactory.create("http://localhost:" + PORT,BookStore.class); Book book=new Book(); book.setId(888); bs.updateBook(book); assertEquals(304,WebClient.client(bs).getResponse().getStatus()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testQuotedHeaders() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/quotedheaders"; WebClient wc=WebClient.create(endpointAddress); WebClient.getConfig(wc).getRequestContext().put("org.apache.cxf.http.header.split",true); Response r=wc.get(); List header1=r.getMetadata().get("SomeHeader1"); assertEquals(1,header1.size()); assertEquals("\"some text, some more text\"",header1.get(0)); List header2=r.getMetadata().get("SomeHeader2"); assertEquals(3,header2.size()); assertEquals("\"some text\"",header2.get(0)); assertEquals("\"quoted,text\"",header2.get(1)); assertEquals("\"even more text\"",header2.get(2)); List header3=r.getMetadata().get("SomeHeader3"); assertEquals(1,header3.size()); assertEquals("\"some text, some more text with inlined \"\"",header3.get(0)); List header4=r.getMetadata().get("SomeHeader4"); assertEquals(1,header4.size()); assertEquals("\"\"",header4.get(0)); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookAcceptWildcard() throws Exception { String address="http://localhost:" + PORT + "/bookstore/books/wildcard"; WebClient wc=WebClient.create(address); Response r=wc.accept("text/*").get(); assertEquals(406,r.getStatus()); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetBookLowCaseHeader() throws Exception { WebClient wc=WebClient.create("http://localhost:" + PORT + "/bookstore/booksecho3"); wc.type("text/plain").accept("text/plain").header("CustomHeader","custom"); String name=wc.post("book",String.class); assertEquals("book",name); assertEquals("custom",wc.getResponse().getHeaderString("CustomHeader")); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testPropogateException() throws Exception { GetMethod get=new GetMethod("http://localhost:" + PORT + "/bookstore/propagate-exception"); get.setRequestHeader("Accept","application/xml"); get.addRequestHeader("Cookie","a=b;c=d"); get.addRequestHeader("Cookie","e=f"); get.setRequestHeader("Accept-Language","da;q=0.8,en"); get.setRequestHeader("Book","1,2,3"); HttpClient httpClient=new HttpClient(); try { int result=httpClient.executeMethod(get); assertEquals(500,result); String content=getStringFromInputStream(get.getResponseBodyAsStream()); assertTrue(content.contains("Error") && content.contains("500")); } finally { get.releaseConnection(); } }

InternalCallVerifier EqualityVerifier 
@Test public void testGetBookFromResponseWithProxyAndReader() throws Exception { BookStore bs=JAXRSClientFactory.create("http://localhost:" + PORT,BookStore.class); Response r=bs.getGenericResponseBook("123"); assertEquals(200,r.getStatus()); Book book=r.readEntity(Book.class); assertEquals(123L,book.getId()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testGetCDsJSON() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/cds"; GetMethod get=new GetMethod(endpointAddress); get.addRequestHeader("Accept","application/json"); HttpClient httpclient=new HttpClient(); try { int result=httpclient.executeMethod(get); assertEquals(200,result); InputStream expected123=getClass().getResourceAsStream("resources/expected_get_cdsjson123.txt"); InputStream expected124=getClass().getResourceAsStream("resources/expected_get_cdsjson124.txt"); assertTrue(get.getResponseBodyAsString().indexOf(getStringFromInputStream(expected123)) >= 0); assertTrue(get.getResponseBodyAsString().indexOf(getStringFromInputStream(expected124)) >= 0); } finally { get.releaseConnection(); } }

APIUtilityVerifier InternalCallVerifier IdentityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetJAXBElementXmlRootBookCollection() throws Exception { BookStore store=JAXRSClientFactory.create("http://localhost:" + PORT,BookStore.class); Book b1=new Book("CXF in Action",123L); Book b2=new Book("CXF Rocks",124L); List> books=new ArrayList>(); books.add(new JAXBElement(new QName("bookRootElement"),Book.class,b1)); books.add(new JAXBElement(new QName("bookRootElement"),Book.class,b2)); List> books2=store.getJAXBElementBookXmlRootCollection(books); assertNotNull(books2); assertNotSame(books,books2); assertEquals(2,books2.size()); Book b11=books2.get(0).getValue(); assertEquals(123L,b11.getId()); assertEquals("CXF in Action",b11.getName()); Book b22=books2.get(1).getValue(); assertEquals(124L,b22.getId()); assertEquals("CXF Rocks",b22.getName()); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testExplicitOptionsNoSplitByDefault() throws Exception { WebClient wc=WebClient.create("http://localhost:" + PORT + "/bookstore/options"); Response response=wc.options(); List values=Arrays.asList(response.getHeaderString("Allow").split(",")); assertNotNull(values); assertTrue(values.contains("POST") && values.contains("GET") && values.contains("DELETE")&& values.contains("PUT")); assertEquals(0,((InputStream)response.getEntity()).available()); List date=response.getMetadata().get("Date"); assertNotNull(date); assertEquals(1,date.size()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testWrongContentType() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/unsupportedcontenttype"; URL url=new URL(endpointAddress); HttpURLConnection urlConnection=(HttpURLConnection)url.openConnection(); urlConnection.setReadTimeout(30000); urlConnection.setConnectTimeout(30000); urlConnection.addRequestProperty("Content-Type","MissingSeparator"); urlConnection.setRequestMethod("POST"); assertEquals(415,urlConnection.getResponseCode()); }

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testServerWebApplicationExceptionWithProxy2() throws Exception { BookStore store=JAXRSClientFactory.create("http://localhost:" + PORT,BookStore.class); try { store.throwException(); fail("Exception expected"); } catch ( WebApplicationException ex) { assertEquals(500,ex.getResponse().getStatus()); assertEquals("This is a WebApplicationException",ex.getResponse().readEntity(String.class)); } }

InternalCallVerifier EqualityVerifier 
@Test public void testGetBookAdapterInterfaceProxy() throws Exception { BookStore store=JAXRSClientFactory.create("http://localhost:" + PORT,BookStore.class); BookInfoInterface info=store.getBookAdapterInterface(); assertEquals(123L,info.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookAsObject() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/object"; WebClient wc=WebClient.create(endpointAddress); Book b=wc.get(Book.class); assertEquals("Book as Object",b.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookByHeaderPerRequestInjectedFault() throws Exception { String address="http://localhost:" + PORT + "/bookstore2/bookheaders/injected"; WebClient wc=WebClient.create(address); wc.accept("application/xml"); wc.header("BOOK","2","3"); Response r=wc.get(); assertEquals(400,r.getStatus()); assertEquals("Param setter: 3 header values are required",r.readEntity(String.class)); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetBookNameAsByteArray(){ String address="http://localhost:" + PORT + "/bookstore/booknames/123"; WebClient wc=WebClient.create(address); Response r=wc.accept("application/bar").get(); String name=r.readEntity(String.class); assertEquals("CXF in Action",name); String lengthStr=r.getHeaderString(HttpHeaders.CONTENT_LENGTH); assertNotNull(lengthStr); long length=Long.valueOf(lengthStr); assertEquals(name.length(),length); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetStringArray() throws Exception { String address="http://localhost:" + PORT; JAXRSClientFactoryBean bean=new JAXRSClientFactoryBean(); bean.setProvider(new BookStore.StringArrayBodyReaderWriter()); bean.setAddress(address); bean.setResourceClass(BookStore.class); BookStore store=bean.create(BookStore.class); String[] str=store.getBookStringArray(); assertEquals("Good book",str[0]); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testPostEmptyForm() throws Exception { String address="http://localhost:" + PORT + "/bookstore/emptyform"; WebClient wc=WebClient.create(address); Response r=wc.form(new Form()); assertEquals("empty form",r.readEntity(String.class)); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetBookSimple222() throws Exception { WebClient wc=WebClient.create("http://localhost:" + PORT + "/simplebooks/222"); Book book=wc.get(Book.class); assertEquals(222L,book.getId()); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetBookSimple() throws Exception { WebClient wc=WebClient.create("http://localhost:" + PORT + "/simplebooks/simple"); Book book=wc.get(Book.class); assertEquals(444L,book.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testPostEmptyFormAsInStream() throws Exception { String address="http://localhost:" + PORT + "/bookstore/emptyform"; WebClient wc=WebClient.create(address); WebClient.getConfig(wc).getRequestContext().put("org.apache.cxf.empty.request",true); wc.type(MediaType.APPLICATION_FORM_URLENCODED); Response r=wc.post(new ByteArrayInputStream("".getBytes())); assertEquals("empty form",r.readEntity(String.class)); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testOptions() throws Exception { WebClient wc=WebClient.create("http://localhost:" + PORT + "/bookstore/bookurl/http%3A%2F%2Ftest.com%2Frss%2F123"); WebClient.getConfig(wc).getRequestContext().put("org.apache.cxf.http.header.split",true); Response response=wc.options(); List values=response.getMetadata().get("Allow"); assertNotNull(values); assertTrue(values.contains("POST") && values.contains("GET") && values.contains("DELETE")&& values.contains("PUT")); assertEquals(0,((InputStream)response.getEntity()).available()); List date=response.getMetadata().get("Date"); assertNotNull(date); assertEquals(1,date.size()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSetManyCookiesWebClient() throws Exception { WebClient client=WebClient.create("http://localhost:" + PORT + "/bookstore/setmanycookies"); Response r=client.type("*/*").get(); assertEquals(200,r.getStatus()); List cookies=r.getMetadata().get("Set-Cookie"); assertNotNull(cookies); assertEquals(3,cookies.size()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testPostGetBookAdapterList() throws Exception { JAXBElementProvider provider=new JAXBElementProvider(); Map outMap=new HashMap(); outMap.put("Books","CollectionWrapper"); outMap.put("books","Book"); provider.setOutTransformElements(outMap); WebClient wc=WebClient.create("http://localhost:" + PORT + "/bookstore/books/adapter-list",Collections.singletonList(provider)); Collection books=wc.type("application/xml").accept("application/xml").postAndGetCollection(new Books(new Book("CXF",123L)),Book.class); assertEquals(1,books.size()); assertEquals(123L,books.iterator().next().getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookDescriptionHttpResponse() throws Exception { String address="http://localhost:" + PORT + "/bookstore/httpresponse"; WebClient wc=WebClient.create(address); WebClient.getConfig(wc).getInInterceptors().add(new LoggingInInterceptor()); Response r=wc.get(); assertEquals("text/plain",r.getMediaType().toString()); assertEquals("Good Book",r.readEntity(String.class)); }

InternalCallVerifier EqualityVerifier 
@Test public void testBookWithSpaceProxyNonEncodedSemicolon() throws Exception { BookStore store=JAXRSClientFactory.create("http://localhost:" + PORT,BookStore.class); Book book=store.getBookWithSemicolon("123;","custom;:header"); assertEquals(123L,book.getId()); assertEquals("CXF in Action;",book.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookByHeaderPerRequestInjected() throws Exception { String address="http://localhost:" + PORT + "/bookstore2/bookheaders/injected"; WebClient wc=WebClient.create(address); wc.accept("application/xml"); wc.header("BOOK","1","2","3"); Book b=wc.get(Book.class); assertEquals(123L,b.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookAdapterInfoList() throws Exception { BookStore store=JAXRSClientFactory.create("http://localhost:" + PORT,BookStore.class); List list=store.getBookAdapterList(); assertEquals(1,list.size()); BookInfo info=list.get(0); assertEquals(123L,info.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetHeadBook123WebClient() throws Exception { String address="http://localhost:" + PORT + "/bookstore/getheadbook/"; WebClient client=WebClient.create(address); Response r=client.head(); assertEquals("HEAD_HEADER_VALUE",r.getMetadata().getFirst("HEAD_HEADER")); }

APIUtilityVerifier InternalCallVerifier IdentityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetJAXBElementXmlRootBookCollectionWebClient() throws Exception { WebClient store=WebClient.create("http://localhost:" + PORT + "/bookstore/jaxbelementxmlrootcollections"); Book b1=new Book("CXF in Action",123L); Book b2=new Book("CXF Rocks",124L); List books=new ArrayList(); books.add(b1); books.add(b2); store.type("application/xml").accept("application/xml"); List books2=new ArrayList(store.postAndGetCollection(books,Book.class,Book.class)); assertNotNull(books2); assertNotSame(books,books2); assertEquals(2,books2.size()); Book b11=books2.get(0); assertEquals(123L,b11.getId()); assertEquals("CXF in Action",b11.getName()); Book b22=books2.get(1); assertEquals(124L,b22.getId()); assertEquals("CXF Rocks",b22.getName()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetBookResponseAndETag() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/books/response/123"; WebClient wc=WebClient.create(endpointAddress); Book book=wc.get(Book.class); assertEquals(200,wc.getResponse().getStatus()); assertEquals(123L,book.getId()); MultivaluedMap headers=wc.getResponse().getMetadata(); assertTrue(headers.size() > 0); Object etag=headers.getFirst("ETag"); assertNotNull(etag); assertTrue(etag.toString().startsWith("\"")); assertTrue(etag.toString().endsWith("\"")); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookByHeaderPerRequestContextFault() throws Exception { String address="http://localhost:" + PORT + "/bookstore2/bookheaders"; WebClient wc=WebClient.create(address); wc.accept("application/xml"); wc.header("BOOK","1","3","4"); Response r=wc.get(); assertEquals(400,r.getStatus()); assertEquals("Context setter: unexpected header value",r.readEntity(String.class)); }

InternalCallVerifier EqualityVerifier 
@Test public void testDropJSONRootDynamically(){ WebClient wc=WebClient.create("http://localhost:" + PORT + "/bookstore/dropjsonroot"); wc.accept("application/json"); String response=wc.get(String.class); assertEquals("{\"id\":123,\"name\":\"CXF in Action\"}",response); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSetCookieWebClient() throws Exception { WebClient client=WebClient.create("http://localhost:" + PORT + "/bookstore/setcookies"); Response r=client.type("*/*").get(); assertEquals(200,r.getStatus()); List cookies=r.getMetadata().get("Set-Cookie"); assertNotNull(cookies); assertEquals(1,cookies.size()); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetBook123WithProxy() throws Exception { BookStore bs=JAXRSClientFactory.create("http://localhost:" + PORT,BookStore.class); Book b=bs.getBook("123"); assertEquals(b.getId(),123); }

InternalCallVerifier EqualityVerifier 
@Test public void testBookWithSpaceProxyPathUrlEncodedSemicolonOnly() throws Exception { JAXRSClientFactoryBean bean=new JAXRSClientFactoryBean(); bean.setServiceClass(BookStore.class); bean.setAddress("http://localhost:" + PORT); bean.getProperties(true).put("url.encode.client.parameters","true"); bean.getProperties(true).put("url.encode.client.parameters.list",";"); BookStore store=bean.create(BookStore.class); Book book=store.getBookWithSemicolon("123;:","custom;:header"); assertEquals(123L,book.getId()); assertEquals("CXF in Action%3B:",book.getName()); }

APIUtilityVerifier InternalCallVerifier IdentityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testPostGetCollectionGenericEntityAndType() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/collections"; WebClient wc=WebClient.create(endpointAddress); wc.accept("application/xml").type("application/xml"); Book b1=new Book("CXF in Action",123L); Book b2=new Book("CXF Rocks",124L); List books=new ArrayList(); books.add(b1); books.add(b2); GenericEntity> genericCollectionEntity=new GenericEntity>(books){ } ; GenericType> genericResponseType=new GenericType>(){ } ; List books2=wc.post(genericCollectionEntity,genericResponseType); assertNotNull(books2); assertNotSame(books,books2); assertEquals(2,books2.size()); Book b11=books.get(0); assertEquals(123L,b11.getId()); assertEquals("CXF in Action",b11.getName()); Book b22=books.get(1); assertEquals(124L,b22.getId()); assertEquals("CXF Rocks",b22.getName()); assertEquals(200,wc.getResponse().getStatus()); }

InternalCallVerifier EqualityVerifier 
@Test public void testBookWithSpaceProxy() throws Exception { BookStore store=JAXRSClientFactory.create("http://localhost:" + PORT,BookStore.class); Book book=store.getBookWithSpace("123"); assertEquals(123L,book.getId()); assertEquals("CXF in Action",book.getName()); }

InternalCallVerifier EqualityVerifier 
@Test public void testAddBookNoBody() throws Exception { PostMethod post=new PostMethod("http://localhost:" + PORT + "/bookstore/books"); post.setRequestHeader("Content-Type","application/xml"); HttpClient httpclient=new HttpClient(); try { int result=httpclient.executeMethod(post); assertEquals(400,result); } finally { post.releaseConnection(); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookFromResponseWithWebClient() throws Exception { String address="http://localhost:" + PORT + "/bookstore/genericresponse/123"; WebClient wc=WebClient.create(address); Response r=wc.accept("application/xml").get(); assertEquals(200,r.getStatus()); Book book=r.readEntity(Book.class); assertEquals(123L,book.getId()); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testOptionsOnSubresource() throws Exception { WebClient wc=WebClient.create("http://localhost:" + PORT + "/bookstore/booksubresource/123"); WebClient.getConfig(wc).getRequestContext().put("org.apache.cxf.http.header.split",true); Response response=wc.options(); List values=response.getMetadata().get("Allow"); assertNotNull(values); assertTrue(!values.contains("POST") && values.contains("GET") && !values.contains("DELETE")&& values.contains("PUT")); assertEquals(0,((InputStream)response.getEntity()).available()); List date=response.getMetadata().get("Date"); assertNotNull(date); assertEquals(1,date.size()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookRelativeUriAutoRedirect() throws Exception { String address="http://localhost:" + PORT + "/bookstore/redirect/relative?loop=false"; WebClient wc=WebClient.create(address); assertEquals(address,wc.getCurrentURI().toString()); WebClient.getConfig(wc).getRequestContext().put("http.redirect.relative.uri","true"); WebClient.getConfig(wc).getHttpConduit().getClient().setAutoRedirect(true); Response r=wc.get(); Book book=r.readEntity(Book.class); assertEquals(124L,book.getId()); String newAddress="http://localhost:" + PORT + "/bookstore/redirect/relative?redirect=true"; assertEquals(newAddress,wc.getCurrentURI().toString()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetBookWithCustomHeader() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/books/123"; WebClient wc=WebClient.create(endpointAddress); Book b=wc.get(Book.class); assertEquals(123L,b.getId()); MultivaluedMap headers=wc.getResponse().getMetadata(); assertEquals("123",headers.getFirst("BookId")); assertEquals(MultivaluedMap.class.getName(),headers.getFirst("MAP-NAME")); assertNotNull(headers.getFirst("Date")); wc.header("PLAIN-MAP","true"); b=wc.get(Book.class); assertEquals(123L,b.getId()); headers=wc.getResponse().getMetadata(); assertEquals("321",headers.getFirst("BookId")); assertEquals(Map.class.getName(),headers.getFirst("MAP-NAME")); assertNotNull(headers.getFirst("Date")); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testEmptyPut() throws Exception { WebClient wc=WebClient.create("http://localhost:" + PORT + "/bookstore/emptyput"); Response response=wc.type("application/json").put(null); assertEquals(204,response.getStatus()); assertNull(response.getMetadata().getFirst("Content-Type")); response=wc.put(""); assertEquals(204,response.getStatus()); assertNull(response.getMetadata().getFirst("Content-Type")); }

InternalCallVerifier EqualityVerifier 
@Test public void testDeleteBookByQuery() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/books/id?value=123"; DeleteMethod post=new DeleteMethod(endpointAddress); HttpClient httpclient=new HttpClient(); try { int result=httpclient.executeMethod(post); assertEquals(200,result); } finally { post.releaseConnection(); } }

InternalCallVerifier EqualityVerifier 
@Test public void testGetBookFromResponseWithProxy() throws Exception { BookStore bs=JAXRSClientFactory.create("http://localhost:" + PORT,BookStore.class); Response r=bs.getGenericResponseBook("123"); assertEquals(200,r.getStatus()); Book book=r.readEntity(Book.class); assertEquals(123L,book.getId()); }

InternalCallVerifier EqualityVerifier 
@Test public void testUpdateBookWithJSON() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/bookswithjson"; File input=new File(getClass().getResource("resources/update_book_json.txt").toURI()); PutMethod put=new PutMethod(endpointAddress); RequestEntity entity=new FileRequestEntity(input,"application/json; charset=ISO-8859-1"); put.setRequestEntity(entity); HttpClient httpclient=new HttpClient(); try { int result=httpclient.executeMethod(put); assertEquals(200,result); InputStream expected=getClass().getResourceAsStream("resources/expected_update_book.txt"); assertEquals(stripXmlInstructionIfNeeded(getStringFromInputStream(expected)),stripXmlInstructionIfNeeded(getStringFromInputStream(put.getResponseBodyAsStream()))); } finally { put.releaseConnection(); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier IgnoredMethod HybridVerifier 
@Test @Ignore public void testProxyUnwrapBookWithXslt() throws Exception { XSLTJaxbProvider provider=new XSLTJaxbProvider(); provider.setInTemplate("classpath:/org/apache/cxf/systest/jaxrs/resources/unwrapbook2.xsl"); BookStore bs=JAXRSClientFactory.create("http://localhost:" + PORT,BookStore.class,Collections.singletonList(provider)); Book book=bs.getWrappedBook2(123L); assertNotNull(book); assertEquals(123L,book.getId()); }

APIUtilityVerifier InternalCallVerifier IdentityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetJAXBElementBookCollection() throws Exception { JAXBElementProvider provider=new JAXBElementProvider(); provider.setMarshallAsJaxbElement(true); provider.setUnmarshallAsJaxbElement(true); BookStore store=JAXRSClientFactory.create("http://localhost:" + PORT,BookStore.class,Collections.singletonList(provider)); BookNoXmlRootElement b1=new BookNoXmlRootElement("CXF in Action",123L); BookNoXmlRootElement b2=new BookNoXmlRootElement("CXF Rocks",124L); List> books=new ArrayList>(); books.add(new JAXBElement(new QName("bookNoXmlRootElement"),BookNoXmlRootElement.class,b1)); books.add(new JAXBElement(new QName("bookNoXmlRootElement"),BookNoXmlRootElement.class,b2)); List> books2=store.getJAXBElementBookCollection(books); assertNotNull(books2); assertNotSame(books,books2); assertEquals(2,books2.size()); BookNoXmlRootElement b11=books.get(0).getValue(); assertEquals(123L,b11.getId()); assertEquals("CXF in Action",b11.getName()); BookNoXmlRootElement b22=books.get(1).getValue(); assertEquals(124L,b22.getId()); assertEquals("CXF Rocks",b22.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testPostGetBookAdapterListJSON() throws Exception { JAXBElementProvider provider=new JAXBElementProvider(); Map outMap=new HashMap(); outMap.put("Books","CollectionWrapper"); outMap.put("books","Book"); provider.setOutTransformElements(outMap); WebClient wc=WebClient.create("http://localhost:" + PORT + "/bookstore/books/adapter-list",Collections.singletonList(provider)); Response r=wc.type("application/xml").accept("application/json").post(new Books(new Book("CXF",123L))); assertEquals("{\"Book\":[{\"id\":123,\"name\":\"CXF\"}]}",IOUtils.readStringFromStream((InputStream)r.getEntity())); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testBookWithMultipleExceptions2() throws Exception { List providers=new LinkedList(); providers.add(new BookServer.NotReturnedExceptionMapper()); providers.add(BookServer.NotFoundExceptionMapper.class); BookStore store=JAXRSClientFactory.create("http://localhost:" + PORT,BookStore.class,providers); try { store.getBookWithExceptions2(true); fail(); } catch ( BookNotReturnedException ex) { assertEquals("notReturned",ex.getMessage()); } try { store.getBookWithExceptions2(false); fail(); } catch ( BookNotFoundFault ex) { assertEquals("notFound",ex.getMessage()); } }

InternalCallVerifier EqualityVerifier 
@Test public void testBookWithSpaceProxyPathUrlEncoded() throws Exception { JAXRSClientFactoryBean bean=new JAXRSClientFactoryBean(); bean.setServiceClass(BookStore.class); bean.setAddress("http://localhost:" + PORT); bean.setProperties(Collections.singletonMap("url.encode.client.parameters",Boolean.TRUE)); BookStore store=bean.create(BookStore.class); Book book=store.getBookWithSemicolon("123;:","custom;:header"); assertEquals(123L,book.getId()); assertEquals("CXF in Action%3B%3A",book.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookAdapterInterfaceList() throws Exception { BookStore store=JAXRSClientFactory.create("http://localhost:" + PORT,BookStore.class); List list=store.getBookAdapterInterfaceList(); assertEquals(1,list.size()); BookInfoInterface info=list.get(0); assertEquals(123L,info.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookUntypedStreamingResponse() throws Exception { String address="http://localhost:" + PORT + "/bookstore/books/streamingresponse"; WebClient wc=WebClient.create(address); Book book=wc.get(Book.class); assertEquals(124L,book.getId()); assertEquals("stream",book.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testEchoBookElement() throws Exception { BookStore store=JAXRSClientFactory.create("http://localhost:" + PORT,BookStore.class); JAXBElement element=store.echoBookElement(new JAXBElement(new QName("","Book"),Book.class,new Book("CXF",123L))); Book book=element.getValue(); assertEquals(123L,book.getId()); assertEquals("CXF",book.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetIntroChapterFromSelectedBook2(){ String address="http://localhost:" + PORT + "/bookstore/"; WebClient wc=WebClient.create(address); wc.path("books[id=le=123]"); wc.path("chapter"); wc.accept("application/xml"); Chapter chapter=wc.get(Chapter.class); assertEquals("chapter 1",chapter.getTitle()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testCapturedServerOutFault() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/outfault"; WebClient wc=WebClient.create(endpointAddress); Response r=wc.get(); assertEquals(403,r.getStatus()); }

Class: org.apache.cxf.systest.jaxrs.JAXRSClientServerNonSpringBookTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetPathFromUriInfo() throws Exception { String address="http://localhost:" + PORT + "/application/bookstore/uifromconstructor"; WebClient wc=WebClient.create(address); wc.accept("text/plain"); String response=wc.get(String.class); assertEquals(address + "?prop=cxf",response); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetBook123UserModelAuthorize() throws Exception { JAXRSClientFactoryBean bean=new JAXRSClientFactoryBean(); bean.setAddress("http://localhost:" + PORT + "/usermodel/bookstore/books"); bean.setUsername("Barry"); bean.setPassword("password"); bean.setModelRef("classpath:org/apache/cxf/systest/jaxrs/resources/resources.xml"); WebClient proxy=bean.createWebClient(); proxy.path("{id}/authorize",123); Book book=proxy.get(Book.class); assertEquals(123L,book.getId()); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testGetNonExistentBook() throws Exception { WebClient wc=WebClient.create("http://localhost:" + PORT + "/application11/thebooks/bookstore/books/321"); try { wc.accept("*/*").get(Book.class); fail(); } catch ( InternalServerErrorException ex) { assertEquals("No book found at all : 321",ex.getResponse().readEntity(String.class)); } }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testBookWithNonExistentMethod() throws Exception { WebClient wc=WebClient.create("http://localhost:" + PORT + "/application11/thebooks/bookstore/nonexistent"); try { wc.accept("*/*").get(Book.class); fail(); } catch ( WebApplicationException ex) { assertEquals("Nonexistent method",ex.getResponse().readEntity(String.class)); } }

InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testGetBooksUserModelInterface() throws Exception { BookStoreNoAnnotationsInterface proxy=JAXRSClientFactory.createFromModel("http://localhost:" + PORT + "/usermodel2",BookStoreNoAnnotationsInterface.class,"classpath:org/apache/cxf/systest/jaxrs/resources/resources2.xml",null); Book book=new Book("From Model",1L); List books=new ArrayList(); books.add(book); books=proxy.getBooks(books); assertEquals(1,books.size()); assertNotSame(book,books.get(0)); assertEquals("From Model",books.get(0).getName()); }

EqualityVerifier 
@Test public void testGetBook123Application11PerRequest() throws Exception { Response r=doTestPerRequest("http://localhost:" + PORT + "/application11/thebooks/bookstore2/bookheaders"); assertEquals("TheBook",r.getHeaderString("BookWriter")); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetBook123ApplicationSingleton() throws Exception { WebClient wc=WebClient.create("http://localhost:" + PORT + "/application/bookstore/default"); wc.accept("application/xml"); Book book=wc.get(Book.class); assertEquals("default",book.getName()); assertEquals(543L,book.getId()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testGetStaticResource() throws Exception { String address="http://localhost:" + PORT + "/singleton/staticmodel.xml"; WebClient wc=WebClient.create(address); String response=wc.get(String.class); assertTrue(response.startsWith("

InternalCallVerifier EqualityVerifier 
@Test public void testUserModelInterfaceOneWay() throws Exception { BookStoreNoAnnotationsInterface proxy=JAXRSClientFactory.createFromModel("http://localhost:" + PORT + "/usermodel2",BookStoreNoAnnotationsInterface.class,"classpath:org/apache/cxf/systest/jaxrs/resources/resources2.xml",null); proxy.pingBookStore(); assertEquals(202,WebClient.client(proxy).getResponse().getStatus()); }

Class: org.apache.cxf.systest.jaxrs.JAXRSClientServerODataSearchTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testSearchBook123WithWebClient() throws Exception { String address="http://localhost:" + PORT + "/bookstore/books/search"; WebClient client=WebClient.create(address); Book b=client.query("$filter","name eq 'CXF*' and id ge 123 and id lt 124").get(Book.class); assertEquals(b.getId(),123L); }

Class: org.apache.cxf.systest.jaxrs.JAXRSClientServerProxySpringBookTest

InternalCallVerifier EqualityVerifier 
@Test public void testGetBookWithRequestScope(){ WebClient wc=WebClient.create("http://localhost:" + PORT + "/test/request/bookstore/booksecho2"); wc.type("text/plain").accept("text/plain"); wc.header("CustomHeader","custom-header"); String value=wc.post("CXF",String.class); assertEquals("CXF",value); assertEquals("custom-header",wc.getResponse().getMetadata().getFirst("CustomHeader")); }

APIUtilityVerifier EqualityVerifier 
@Test public void testGetBook123() throws Exception { String endpointAddress="http://localhost:" + PORT + "/test/bookstore/books/123"; URL url=new URL(endpointAddress); URLConnection connect=url.openConnection(); connect.addRequestProperty("Accept","application/json"); InputStream in=connect.getInputStream(); InputStream expected=getClass().getResourceAsStream("resources/expected_get_book123json.txt"); assertEquals(getStringFromInputStream(expected),getStringFromInputStream(in)); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetName() throws Exception { String endpointAddress="http://localhost:" + PORT + "/test/v1/names/1"; WebClient wc=WebClient.create(endpointAddress); wc.accept("application/json"); String name=wc.get(String.class); assertEquals("{\"name\":\"Barry\"}",name); }

APIUtilityVerifier EqualityVerifier 
@Test public void testGetThatBookInterfacePrototype() throws Exception { URL url=new URL("http://localhost:" + PORT + "/test/5/bookstorestorage/thosebooks/123"); URLConnection connect=url.openConnection(); connect.addRequestProperty("Content-Type","*/*"); connect.addRequestProperty("Accept","application/xml"); connect.addRequestProperty("SpringProxy","true"); InputStream in=connect.getInputStream(); InputStream expected=getClass().getResourceAsStream("resources/expected_get_book123.txt"); assertEquals(stripXmlInstructionIfNeeded(getStringFromInputStream(expected)),stripXmlInstructionIfNeeded(getStringFromInputStream(in))); String ct=connect.getHeaderField("Content-Type"); assertEquals("application/xml;a=b",ct); }

APIUtilityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetBookNotFound() throws Exception { String endpointAddress="http://localhost:" + PORT + "/test/bookstore/books/12345"; URL url=new URL(endpointAddress); HttpURLConnection connect=(HttpURLConnection)url.openConnection(); connect.addRequestProperty("Accept","text/plain,application/xml"); assertEquals(500,connect.getResponseCode()); InputStream in=connect.getErrorStream(); assertNotNull(in); InputStream expected=getClass().getResourceAsStream("resources/expected_get_book_notfound_mapped.txt"); assertEquals("Exception is not mapped correctly",stripXmlInstructionIfNeeded(getStringFromInputStream(expected).trim()),stripXmlInstructionIfNeeded(getStringFromInputStream(in).trim())); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testPutName() throws Exception { String endpointAddress="http://localhost:" + PORT + "/test/v1/names/1"; WebClient wc=WebClient.create(endpointAddress); wc.type("application/json").accept("application/json"); String id=wc.put(null,String.class); assertEquals("1",id); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetWadlResourcesInfo() throws Exception { WebClient client=WebClient.create("http://localhost:" + PORT + "/test"+ "?_wadl&_type=xml"); WebClient.getConfig(client).getHttpConduit().getClient().setReceiveTimeout(10000000); Document doc=StaxUtils.read(new InputStreamReader(client.get(InputStream.class),StandardCharsets.UTF_8)); Element root=doc.getDocumentElement(); assertEquals(WadlGenerator.WADL_NS,root.getNamespaceURI()); assertEquals("application",root.getLocalName()); List resourcesEls=DOMUtils.getChildrenWithName(root,WadlGenerator.WADL_NS,"resources"); assertEquals(1,resourcesEls.size()); Element resourcesEl=resourcesEls.get(0); assertEquals("http://localhost:" + PORT + "/test/",resourcesEl.getAttribute("base")); List resourceEls=DOMUtils.getChildrenWithName(resourcesEl,WadlGenerator.WADL_NS,"resource"); assertEquals(3,resourceEls.size()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testEchoBook() throws Exception { URL url=new URL("http://localhost:" + PORT + "/test/5/bookstorestorage/thosebooks"); WebClient wc=WebClient.create(url.toString(),Collections.singletonList(new CustomJaxbElementProvider())); Response r=wc.post(new Book("proxy",333L)); Book book=r.readEntity(Book.class); assertEquals(333L,book.getId()); String ct=r.getHeaderString("Content-Type"); assertEquals("application/xml;a=b",ct); }

Class: org.apache.cxf.systest.jaxrs.JAXRSClientServerResourceCreatedOutsideBookTest

APIUtilityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetBook123() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/books/123"; URL url=new URL(endpointAddress); URLConnection connect=url.openConnection(); connect.addRequestProperty("Accept","application/xml"); InputStream in=connect.getInputStream(); assertNotNull(in); InputStream expected=getClass().getResourceAsStream("resources/expected_get_book123.txt"); assertEquals(stripXmlInstructionIfNeeded(getStringFromInputStream(expected)),stripXmlInstructionIfNeeded(getStringFromInputStream(in))); }

APIUtilityVerifier EqualityVerifier 
@Test public void testAddBookHTTPURL() throws Exception { String endpointAddress="http://localhost:" + PORT + "/bookstore/books"; URL url=new URL(endpointAddress); HttpURLConnection httpUrlConnection=(HttpURLConnection)url.openConnection(); httpUrlConnection.setUseCaches(false); httpUrlConnection.setDefaultUseCaches(false); httpUrlConnection.setDoOutput(true); httpUrlConnection.setDoInput(true); httpUrlConnection.setRequestMethod("POST"); httpUrlConnection.setRequestProperty("Accept","text/xml"); httpUrlConnection.setRequestProperty("Content-type","application/xml"); httpUrlConnection.setRequestProperty("Connection","close"); OutputStream outputstream=httpUrlConnection.getOutputStream(); File inputFile=new File(getClass().getResource("resources/add_book.txt").toURI()); byte[] tmp=new byte[4096]; int i=0; try (InputStream is=new FileInputStream(inputFile)){ while ((i=is.read(tmp)) >= 0) { outputstream.write(tmp,0,i); } } outputstream.flush(); int responseCode=httpUrlConnection.getResponseCode(); assertEquals(200,responseCode); InputStream expected=getClass().getResourceAsStream("resources/expected_add_book.txt"); assertEquals(stripXmlInstructionIfNeeded(getStringFromInputStream(expected)),stripXmlInstructionIfNeeded(getStringFromInputStream(httpUrlConnection.getInputStream()))); httpUrlConnection.disconnect(); }

Class: org.apache.cxf.systest.jaxrs.JAXRSClientServerResourceCreatedSpringBookTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookSimpleProxy() throws Exception { String address="http://localhost:" + PORT + "/webapp/rest"; BookStoreSimple bookStore=JAXRSClientFactory.create(address,BookStoreSimple.class); Book book=bookStore.getBook(444L); assertEquals(444L,book.getId()); }

APIUtilityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testPetStore() throws Exception { String endpointAddress="http://localhost:" + PORT + "/webapp/rest/petstore/pets/24"; URL url=new URL(endpointAddress); URLConnection connect=url.openConnection(); connect.addRequestProperty("Accept","text/xml"); InputStream in=connect.getInputStream(); assertNotNull(in); assertEquals(PetStore.CLOSED,getStringFromInputStream(in)); }

EqualityVerifier 
@Test public void testGetBookSimple() throws Exception { String address="http://localhost:" + PORT + "/webapp/rest/simplebooks/444"; assertEquals(444L,WebClient.create(address).get(Book.class).getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookSimpleBeanParamProxy() throws Exception { String address="http://localhost:" + PORT + "/webapp/rest"; BookStoreSimple bookStore=JAXRSClientFactory.create(address,BookStoreSimple.class); Book book=bookStore.getBookBeanParam(new BookStoreSimple.BookBean(444)); assertEquals(444L,book.getId()); }

EqualityVerifier 
@Test public void testGetBookSimpleMatrixMiddle() throws Exception { String address="http://localhost:" + PORT + "/webapp/rest/simplebooks/444;bookId=ssn/book"; assertEquals(444L,WebClient.create(address).get(Book.class).getId()); }

APIUtilityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetBook123() throws Exception { String endpointAddress="http://localhost:" + PORT + "/webapp/rest/bookstore/books/123"; URL url=new URL(endpointAddress); URLConnection connect=url.openConnection(); connect.addRequestProperty("Accept","application/xml"); InputStream in=connect.getInputStream(); assertNotNull(in); InputStream expected=getClass().getResourceAsStream("resources/expected_get_book123.txt"); assertEquals(stripXmlInstructionIfNeeded(getStringFromInputStream(expected)),stripXmlInstructionIfNeeded(getStringFromInputStream(in))); }

EqualityVerifier 
@Test public void testGetBookSimpleMatrixEnd() throws Exception { String address="http://localhost:" + PORT + "/webapp/rest/simplebooks/444;bookId=ssn"; assertEquals(444L,WebClient.create(address).get(Book.class).getId()); }

Class: org.apache.cxf.systest.jaxrs.JAXRSClientServerResourceCreatedSpringProviderTest

APIUtilityVerifier EqualityVerifier 
@Test public void testPostPetStatus() throws Exception { String endpointAddress="http://localhost:" + PORT + "/webapp/pets/petstore/pets"; URL url=new URL(endpointAddress); HttpURLConnection httpUrlConnection=(HttpURLConnection)url.openConnection(); httpUrlConnection.setUseCaches(false); httpUrlConnection.setDefaultUseCaches(false); httpUrlConnection.setDoOutput(true); httpUrlConnection.setDoInput(true); httpUrlConnection.setRequestMethod("POST"); httpUrlConnection.setRequestProperty("Accept","text/xml"); httpUrlConnection.setRequestProperty("Content-type","application/x-www-form-urlencoded"); httpUrlConnection.setRequestProperty("Connection","close"); OutputStream outputstream=httpUrlConnection.getOutputStream(); File inputFile=new File(getClass().getResource("resources/singleValPostBody.txt").toURI()); byte[] tmp=new byte[4096]; int i=0; try (InputStream is=new FileInputStream(inputFile)){ while ((i=is.read(tmp)) >= 0) { outputstream.write(tmp,0,i); } } outputstream.flush(); int responseCode=httpUrlConnection.getResponseCode(); assertEquals(200,responseCode); assertEquals("Wrong status returned","open",getStringFromInputStream(httpUrlConnection.getInputStream())); httpUrlConnection.disconnect(); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testPostPetStatusType() throws Exception { JAXBElementProvider p=new JAXBElementProvider(); p.setUnmarshallAsJaxbElement(true); WebClient wc=WebClient.create("http://localhost:" + PORT + "/webapp/pets/petstore/jaxb/statusType/",Collections.singletonList(p)); WebClient.getConfig(wc).getInInterceptors().add(new LoggingInInterceptor()); wc.accept("text/xml"); PetStore.PetStoreStatusType type=wc.get(PetStore.PetStoreStatusType.class); assertEquals(PetStore.CLOSED,type.getStatus()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testBasePetStoreWithoutTrailingSlash() throws Exception { String endpointAddress="http://localhost:" + PORT + "/webapp/pets"; WebClient client=WebClient.create(endpointAddress); HTTPConduit conduit=WebClient.getConfig(client).getHttpConduit(); conduit.getClient().setReceiveTimeout(1000000); conduit.getClient().setConnectionTimeout(1000000); String value=client.accept("text/plain").get(String.class); assertEquals(PetStore.CLOSED,value); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testServletConfigInitParam() throws Exception { String endpointAddress="http://localhost:" + PORT + "/webapp/resources/servlet/config/a"; WebClient wc=WebClient.create(endpointAddress); wc.accept("text/plain"); assertEquals("avalue",wc.get(String.class)); }

APIUtilityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetBookNotFound() throws Exception { String endpointAddress="http://localhost:" + PORT + "/webapp/resources/bookstore/books/12345"; URL url=new URL(endpointAddress); HttpURLConnection connect=(HttpURLConnection)url.openConnection(); connect.addRequestProperty("Accept","text/plain,application/xml"); assertEquals(500,connect.getResponseCode()); InputStream in=connect.getErrorStream(); assertNotNull(in); InputStream expected=getClass().getResourceAsStream("resources/expected_get_book_notfound_mapped.txt"); assertEquals("Exception is not mapped correctly",stripXmlInstructionIfNeeded(getStringFromInputStream(expected).trim()),stripXmlInstructionIfNeeded(getStringFromInputStream(in).trim())); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testBasePetStore() throws Exception { String endpointAddress="http://localhost:" + PORT + "/webapp/pets/"; WebClient client=WebClient.create(endpointAddress); HTTPConduit conduit=WebClient.getConfig(client).getHttpConduit(); conduit.getClient().setReceiveTimeout(1000000); conduit.getClient().setConnectionTimeout(1000000); String value=client.accept("text/plain").get(String.class); assertEquals(PetStore.CLOSED,value); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testWadlPublishedEndpointUrl() throws Exception { String requestURI="http://localhost:" + PORT + "/webapp/resources2"; WebClient client=WebClient.create(requestURI + "?_wadl&_type=xml"); Document doc=StaxUtils.read(new InputStreamReader(client.get(InputStream.class),StandardCharsets.UTF_8)); Element root=doc.getDocumentElement(); assertEquals(WadlGenerator.WADL_NS,root.getNamespaceURI()); assertEquals("application",root.getLocalName()); List resourcesEls=DOMUtils.getChildrenWithName(root,WadlGenerator.WADL_NS,"resources"); assertEquals(1,resourcesEls.size()); Element resourcesEl=resourcesEls.get(0); assertEquals("http://proxy",resourcesEl.getAttribute("base")); }

APIUtilityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetBookNotExistent() throws Exception { String endpointAddress="http://localhost:" + PORT + "/webapp/resources/bookstore/nonexistent"; URL url=new URL(endpointAddress); HttpURLConnection connect=(HttpURLConnection)url.openConnection(); connect.addRequestProperty("Accept","application/xml"); assertEquals(405,connect.getResponseCode()); InputStream in=connect.getErrorStream(); assertNotNull(in); assertEquals("Exception is not mapped correctly","StringTextWriter - Nonexistent method",getStringFromInputStream(in).trim()); }

APIUtilityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetBook123() throws Exception { String endpointAddress="http://localhost:" + PORT + "/webapp/resources/bookstore/books/123"; URL url=new URL(endpointAddress); URLConnection connect=url.openConnection(); connect.addRequestProperty("Accept","application/json"); connect.addRequestProperty("Content-Language","badgerFishLanguage"); InputStream in=connect.getInputStream(); assertNotNull(in); InputStream expected=getClass().getResourceAsStream("resources/expected_get_book123badgerfish.txt"); assertEquals("BadgerFish output not correct",stripXmlInstructionIfNeeded(getStringFromInputStream(expected).trim()),stripXmlInstructionIfNeeded(getStringFromInputStream(in).trim())); }

Class: org.apache.cxf.systest.jaxrs.JAXRSClientServerResourceJacksonSpringProviderTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testMultipart() throws Exception { String endpointAddress="http://localhost:" + PORT + "/webapp/multipart"; MultipartStore proxy=JAXRSClientFactory.create(endpointAddress,MultipartStore.class,Collections.singletonList(new JacksonJsonProvider())); Book json=new Book("json",1L); InputStream is1=getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/java.jpg"); Map attachments=proxy.addBookJsonImageStream(json,is1); assertEquals(2,attachments.size()); Book json2=((Attachment)attachments.get("application/json")).getObject(Book.class); assertEquals("json",json2.getName()); assertEquals(1L,json2.getId()); InputStream is2=((Attachment)attachments.get("application/octet-stream")).getObject(InputStream.class); byte[] image1=IOUtils.readBytesFromStream(getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/java.jpg")); byte[] image2=IOUtils.readBytesFromStream(is2); assertTrue(Arrays.equals(image1,image2)); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testEchoSuperBookProxy() throws Exception { String endpointAddress="http://localhost:" + PORT + "/webapp/store2"; BookStoreSpring proxy=JAXRSClientFactory.create(endpointAddress,BookStoreSpring.class,Collections.singletonList(new JacksonJsonProvider())); SuperBook book=proxy.echoSuperBookJson(new SuperBook("Super",124L,true)); assertEquals(124L,book.getId()); assertTrue(book.isSuperBook()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetSuperBookProxy() throws Exception { String endpointAddress="http://localhost:" + PORT + "/webapp/store2"; BookStoreSpring proxy=JAXRSClientFactory.create(endpointAddress,BookStoreSpring.class,Collections.singletonList(new JacksonJsonProvider())); SuperBook book=proxy.getSuperBookJson(); assertEquals(999L,book.getId()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testEchoGenericSuperBookCollectionProxy() throws Exception { String endpointAddress="http://localhost:" + PORT + "/webapp/custombus/genericstore"; GenericBookStoreSpring proxy=JAXRSClientFactory.create(endpointAddress,GenericBookStoreSpring.class,Collections.singletonList(new JacksonJsonProvider())); List books=proxy.echoSuperBookCollectionJson(Collections.singletonList(new SuperBook("Super",124L,true))); assertEquals(124L,books.get(0).getId()); assertTrue(books.get(0).isSuperBook()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testEchoGenericSuperBookProxy2JsonType() throws Exception { String endpointAddress="http://localhost:" + PORT + "/webapp/genericstore2type"; GenericBookStoreSpring2 proxy=JAXRSClientFactory.create(endpointAddress,GenericBookStoreSpring2.class,Collections.singletonList(new JacksonJsonProvider())); WebClient.getConfig(proxy).getHttpConduit().getClient().setReceiveTimeout(1000000000L); WebClient.client(proxy).type("application/json").accept("application/json"); SuperBook2 book=proxy.echoSuperBookType(new SuperBook2("Super",124L,true)); assertEquals(124L,book.getId()); assertTrue(book.isSuperBook()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetSuperBookCollectionProxy() throws Exception { String endpointAddress="http://localhost:" + PORT + "/webapp/store2"; BookStoreSpring proxy=JAXRSClientFactory.create(endpointAddress,BookStoreSpring.class,Collections.singletonList(new JacksonJsonProvider())); List books=proxy.getSuperBookCollectionJson(); assertEquals(999L,books.get(0).getId()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testEchoGenericSuperBookCollectionProxy2XmlType() throws Exception { String endpointAddress="http://localhost:" + PORT + "/webapp/genericstore2type"; JAXBElementProvider jaxbProvider=new JAXBElementProvider(); jaxbProvider.setMarshallAsJaxbElement(true); jaxbProvider.setUnmarshallAsJaxbElement(true); GenericBookStoreSpring2 proxy=JAXRSClientFactory.create(endpointAddress,GenericBookStoreSpring2.class,Collections.singletonList(jaxbProvider)); WebClient.client(proxy).type("application/xml").accept("application/xml"); WebClient.getConfig(proxy).getHttpConduit().getClient().setReceiveTimeout(1000000000L); List books=proxy.echoSuperBookTypeCollection(Collections.singletonList(new SuperBook2("Super",124L,true))); assertEquals(124L,books.get(0).getId()); assertTrue(books.get(0).isSuperBook()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testEchoGenericSuperBookProxy2Xml() throws Exception { String endpointAddress="http://localhost:" + PORT + "/webapp/genericstore2"; JAXBElementProvider jaxbProvider=new JAXBElementProvider(); jaxbProvider.setXmlRootAsJaxbElement(true); jaxbProvider.setMarshallAsJaxbElement(true); GenericBookStoreSpring2 proxy=JAXRSClientFactory.create(endpointAddress,GenericBookStoreSpring2.class,Collections.singletonList(jaxbProvider)); WebClient.getConfig(proxy).getHttpConduit().getClient().setReceiveTimeout(1000000000L); WebClient.client(proxy).type("application/xml").accept("application/xml"); SuperBook book=proxy.echoSuperBook(new SuperBook("Super",124L,true)); assertEquals(124L,book.getId()); assertTrue(book.isSuperBook()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testEchoGenericSuperBookCollectionWebClient() throws Exception { String endpointAddress="http://localhost:" + PORT + "/webapp/custombus/genericstore/books/superbooks"; WebClient wc=WebClient.create(endpointAddress,Collections.singletonList(new JacksonJsonProvider())); WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(100000000L); wc.accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON); Collection books=wc.postAndGetCollection(Collections.singletonList(new SuperBook("Super",124L,true)),SuperBook.class,SuperBook.class); SuperBook book=books.iterator().next(); assertEquals(124L,book.getId()); assertTrue(book.isSuperBook()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testGetGenericSuperBookCollectionWebClient() throws Exception { String endpointAddress="http://localhost:" + PORT + "/webapp/custombus/genericstore/books/superbooks2"; WebClient wc=WebClient.create(endpointAddress,Collections.singletonList(new JacksonJsonProvider())); WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(100000000L); wc.accept(MediaType.APPLICATION_JSON); List books=wc.get(new GenericType>(){ } ); SuperBook book=books.iterator().next(); assertEquals(124L,book.getId()); assertTrue(book.isSuperBook()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testEchoGenericSuperBookProxy() throws Exception { String endpointAddress="http://localhost:" + PORT + "/webapp/custombus/genericstore"; GenericBookStoreSpring proxy=JAXRSClientFactory.create(endpointAddress,GenericBookStoreSpring.class,Collections.singletonList(new JacksonJsonProvider())); WebClient.getConfig(proxy).getHttpConduit().getClient().setReceiveTimeout(1000000000L); SuperBook book=proxy.echoSuperBookJson(new SuperBook("Super",124L,true)); assertEquals(124L,book.getId()); assertTrue(book.isSuperBook()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testEchoGenericSuperBookProxy2Json() throws Exception { String endpointAddress="http://localhost:" + PORT + "/webapp/genericstore2"; GenericBookStoreSpring2 proxy=JAXRSClientFactory.create(endpointAddress,GenericBookStoreSpring2.class,Collections.singletonList(new JacksonJsonProvider())); WebClient.getConfig(proxy).getHttpConduit().getClient().setReceiveTimeout(1000000000L); WebClient.client(proxy).type("application/json").accept("application/json"); SuperBook book=proxy.echoSuperBook(new SuperBook("Super",124L,true)); assertEquals(124L,book.getId()); assertTrue(book.isSuperBook()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testEchoGenericSuperBookCollectionProxy2Json() throws Exception { String endpointAddress="http://localhost:" + PORT + "/webapp/genericstore2"; GenericBookStoreSpring2 proxy=JAXRSClientFactory.create(endpointAddress,GenericBookStoreSpring2.class,Collections.singletonList(new JacksonJsonProvider())); WebClient.client(proxy).type("application/json").accept("application/json"); List books=proxy.echoSuperBookCollection(Collections.singletonList(new SuperBook("Super",124L,true))); assertEquals(124L,books.get(0).getId()); assertTrue(books.get(0).isSuperBook()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testEchoGenericSuperBookProxy2XmlType() throws Exception { String endpointAddress="http://localhost:" + PORT + "/webapp/genericstore2type"; JAXBElementProvider jaxbProvider=new JAXBElementProvider(); jaxbProvider.setMarshallAsJaxbElement(true); jaxbProvider.setUnmarshallAsJaxbElement(true); GenericBookStoreSpring2 proxy=JAXRSClientFactory.create(endpointAddress,GenericBookStoreSpring2.class,Collections.singletonList(jaxbProvider)); WebClient.getConfig(proxy).getHttpConduit().getClient().setReceiveTimeout(1000000000L); WebClient.client(proxy).type("application/xml").accept("application/xml"); SuperBook2 book=proxy.echoSuperBookType(new SuperBook2("Super",124L,true)); assertEquals(124L,book.getId()); assertTrue(book.isSuperBook()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testEchoGenericSuperBookWebClientXml() throws Exception { String endpointAddress="http://localhost:" + PORT + "/webapp/custombus/genericstore/books/superbook"; WebClient wc=WebClient.create(endpointAddress); wc.accept(MediaType.APPLICATION_XML).type(MediaType.APPLICATION_XML); SuperBook book=wc.post(new SuperBook("Super",124L,true),SuperBook.class); assertEquals(124L,book.getId()); assertTrue(book.isSuperBook()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testEchoGenericSuperBookCollectionWebClientXml() throws Exception { String endpointAddress="http://localhost:" + PORT + "/webapp/custombus/genericstore/books/superbooks"; WebClient wc=WebClient.create(endpointAddress); wc.accept(MediaType.APPLICATION_XML).type(MediaType.APPLICATION_XML); Collection books=wc.postAndGetCollection(Collections.singletonList(new SuperBook("Super",124L,true)),SuperBook.class,SuperBook.class); SuperBook book=books.iterator().next(); assertEquals(124L,book.getId()); assertTrue(book.isSuperBook()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testEchoGenericSuperBookWebClient() throws Exception { String endpointAddress="http://localhost:" + PORT + "/webapp/custombus/genericstore/books/superbook"; WebClient wc=WebClient.create(endpointAddress,Collections.singletonList(new JacksonJsonProvider())); wc.accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON); SuperBook book=wc.post(new SuperBook("Super",124L,true),SuperBook.class); assertEquals(124L,book.getId()); assertTrue(book.isSuperBook()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testEchoGenericSuperBookCollectionProxy2Xml() throws Exception { String endpointAddress="http://localhost:" + PORT + "/webapp/genericstore2"; JAXBElementProvider jaxbProvider=new JAXBElementProvider(); jaxbProvider.setMarshallAsJaxbElement(true); jaxbProvider.setUnmarshallAsJaxbElement(true); GenericBookStoreSpring2 proxy=JAXRSClientFactory.create(endpointAddress,GenericBookStoreSpring2.class,Collections.singletonList(jaxbProvider)); WebClient.client(proxy).type("application/xml").accept("application/xml"); WebClient.getConfig(proxy).getHttpConduit().getClient().setReceiveTimeout(1000000000L); List books=proxy.echoSuperBookCollection(Collections.singletonList(new SuperBook("Super",124L,true))); assertEquals(124L,books.get(0).getId()); assertTrue(books.get(0).isSuperBook()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetCollectionOfBooks() throws Exception { String endpointAddress="http://localhost:" + PORT + "/webapp/store1/bookstore/collections"; WebClient wc=WebClient.create(endpointAddress,Collections.singletonList(new JacksonJsonProvider())); wc.accept("application/json"); Collection collection=wc.getCollection(Book.class); assertEquals(1,collection.size()); Book book=collection.iterator().next(); assertEquals(123L,book.getId()); }

APIUtilityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetBook123() throws Exception { String endpointAddress="http://localhost:" + PORT + "/webapp/store1/bookstore/books/123"; URL url=new URL(endpointAddress); URLConnection connect=url.openConnection(); connect.addRequestProperty("Accept","application/json"); InputStream in=connect.getInputStream(); assertNotNull(in); assertEquals("Jackson output not correct","{\"class\":\"org.apache.cxf.systest.jaxrs.Book\",\"name\":\"CXF in Action\",\"id\":123}",getStringFromInputStream(in).trim()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetCollectionOfSuperBooks() throws Exception { String endpointAddress="http://localhost:" + PORT + "/webapp/store2/books/superbooks"; WebClient wc=WebClient.create(endpointAddress,Collections.singletonList(new JacksonJsonProvider())); wc.accept("application/json"); Collection collection=wc.getCollection(Book.class); assertEquals(1,collection.size()); Book book=collection.iterator().next(); assertEquals(999L,book.getId()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testEchoSuperBookCollectionProxy() throws Exception { String endpointAddress="http://localhost:" + PORT + "/webapp/store2"; BookStoreSpring proxy=JAXRSClientFactory.create(endpointAddress,BookStoreSpring.class,Collections.singletonList(new JacksonJsonProvider())); WebClient.getConfig(proxy).getHttpConduit().getClient().setReceiveTimeout(10000000L); List books=proxy.echoSuperBookCollectionJson(Collections.singletonList(new SuperBook("Super",124L,true))); assertEquals(124L,books.get(0).getId()); assertTrue(books.get(0).isSuperBook()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetGenericSuperBookInt1() throws Exception { String endpointAddress="http://localhost:" + PORT + "/webapp/genericstoreInt1/int/books/superbook"; WebClient wc=WebClient.create(endpointAddress,Collections.singletonList(new JacksonJsonProvider())); WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(1000000000L); GenericType> genericResponseType=new GenericType>(){ } ; List books=wc.get(genericResponseType); assertEquals(1,books.size()); assertEquals(111L,books.get(0).getId()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testEchoGenericSuperBookCollectionProxy2JsonType() throws Exception { String endpointAddress="http://localhost:" + PORT + "/webapp/genericstore2type"; GenericBookStoreSpring2 proxy=JAXRSClientFactory.create(endpointAddress,GenericBookStoreSpring2.class,Collections.singletonList(new JacksonJsonProvider())); WebClient.client(proxy).type("application/json").accept("application/json"); List books=proxy.echoSuperBookTypeCollection(Collections.singletonList(new SuperBook2("Super",124L,true))); assertEquals(124L,books.get(0).getId()); assertTrue(books.get(0).isSuperBook()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetGenericSuperBookInt2() throws Exception { String endpointAddress="http://localhost:" + PORT + "/webapp/genericstoreInt2"; GenericBookServiceInterface proxy=JAXRSClientFactory.create(endpointAddress,GenericBookServiceInterface.class,Collections.singletonList(new JacksonJsonProvider())); WebClient.getConfig(proxy).getHttpConduit().getClient().setReceiveTimeout(1000000000L); List books=proxy.getSuperBook(); assertEquals(1,books.size()); assertEquals(111L,books.get(0).getId()); }

Class: org.apache.cxf.systest.jaxrs.JAXRSClientServerSpringBookTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookWithEncodedSemicolonAndMatrixParam() throws Exception { String endpointAddress="http://localhost:" + PORT + "/the/thebooks/bookstore/semicolon2%3B;a=b"; WebClient client=WebClient.create(endpointAddress); WebClient.getConfig(client).getHttpConduit().getClient().setReceiveTimeout(1000000); Book book=client.get(Book.class); assertEquals(333L,book.getId()); assertEquals(";b",book.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testPostBookXsiTypeProxy() throws Exception { String address="http://localhost:" + PORT + "/the/thebooksxsi/bookstore"; JAXBElementProvider provider=new JAXBElementProvider(); provider.setExtraClass(new Class[]{SuperBook.class}); provider.setJaxbElementClassNames(Collections.singletonList(Book.class.getName())); BookStoreSpring bookStore=JAXRSClientFactory.create(address,BookStoreSpring.class,Collections.singletonList(provider)); SuperBook book=new SuperBook("SuperBook2",999L,true); Book book2=bookStore.postGetBookXsiType(book); assertEquals("SuperBook2",book2.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testEchoBookForm() throws Exception { String address="http://localhost:" + PORT + "/bus/thebooksform/bookform"; WebClient wc=WebClient.create(address); Book b=wc.form(new Form().param("name","CXFForm").param("id","125")).readEntity(Book.class); assertEquals("CXFForm",b.getName()); assertEquals(125L,b.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testPostBookXsiType() throws Exception { String address="http://localhost:" + PORT + "/the/thebooksxsi/bookstore/books/xsitype"; JAXBElementProvider provider=new JAXBElementProvider(); provider.setExtraClass(new Class[]{SuperBook.class}); provider.setJaxbElementClassNames(Collections.singletonList(Book.class.getName())); WebClient wc=WebClient.create(address,Collections.singletonList(provider)); wc.accept("application/xml"); wc.type("application/xml"); SuperBook book=new SuperBook("SuperBook2",999L,true); Book book2=wc.invoke("POST",book,Book.class,Book.class); assertEquals("SuperBook2",book2.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookWithoutJsonpCallback() throws Exception { String url="http://localhost:" + PORT + "/the/jsonp/books/123"; WebClient client=WebClient.create(url); client.accept("application/json, application/x-javascript"); WebClient.getConfig(client).getHttpConduit().getClient().setReceiveTimeout(1000000L); Response r=client.get(); assertEquals("application/json",r.getMetadata().getFirst("Content-Type")); assertEquals("{\"Book\":{\"id\":123,\"name\":\"CXF in Action\"}}",IOUtils.readStringFromStream((InputStream)r.getEntity())); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testBookDepthExceededXMLSourceStax() throws Exception { String endpointAddress="http://localhost:" + PORT + "/the/thebooks9stax/depth-source"; WebClient wc=WebClient.create(endpointAddress); Response r=wc.post(new Book("CXF",123L)); assertEquals(413,r.getStatus()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testBookDepthExceededJettison() throws Exception { String endpointAddress="http://localhost:" + PORT + "/the/thebooks10/depth"; WebClient wc=WebClient.create(endpointAddress); wc.accept("application/json").type("application/json"); Response r=wc.post(new Book("CXF",123L)); assertEquals(413,r.getStatus()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testBookDepthExceededXMLDomStax() throws Exception { String endpointAddress="http://localhost:" + PORT + "/the/thebooks9stax/depth-dom"; WebClient wc=WebClient.create(endpointAddress); Response r=wc.post(new Book("CXF",123L)); assertEquals(413,r.getStatus()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testTooManyFormParams() throws Exception { String endpointAddress="http://localhost:" + PORT + "/the/thebooks9/depth-form"; WebClient wc=WebClient.create(endpointAddress); Response r=wc.form(new Form().param("a","b")); assertEquals(204,r.getStatus()); r=wc.form(new Form().param("a","b").param("c","b")); assertEquals(413,r.getStatus()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testPostGeneratedBook() throws Exception { String baseAddress="http://localhost:" + PORT + "/the/generated"; JAXBElementProvider provider=new JAXBElementProvider(); provider.setJaxbElementClassMap(Collections.singletonMap("org.apache.cxf.systest.jaxrs.codegen.schema.Book","{http://superbooks}thebook")); org.apache.cxf.systest.jaxrs.codegen.service.BookStore bookStore=JAXRSClientFactory.create(baseAddress,org.apache.cxf.systest.jaxrs.codegen.service.BookStore.class,Collections.singletonList(provider)); org.apache.cxf.systest.jaxrs.codegen.schema.Book book=new org.apache.cxf.systest.jaxrs.codegen.schema.Book(); book.setId(123); bookStore.addBook(123,book); Response r=WebClient.client(bookStore).getResponse(); assertEquals(204,r.getStatus()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testBookDepthExceededXMLSource() throws Exception { String endpointAddress="http://localhost:" + PORT + "/the/thebooks9/depth-source"; WebClient wc=WebClient.create(endpointAddress); WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(1000000L); Response r=wc.post(new Book("CXF",123L)); assertEquals(413,r.getStatus()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testEchoBookFormXml() throws Exception { String address="http://localhost:" + PORT + "/bus/thebooksform/bookform"; WebClient wc=WebClient.create(address); WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(10000000L); Book b=wc.type("application/xml").post(new Book("CXFFormXml",125L)).readEntity(Book.class); assertEquals("CXFFormXml",b.getName()); assertEquals(125L,b.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookJsonp() throws Exception { String url="http://localhost:" + PORT + "/the/jsonp/books/123"; WebClient client=WebClient.create(url); client.accept("application/json, application/x-javascript"); client.query("_jsonp","callback"); Response r=client.get(); assertEquals("application/x-javascript",r.getMetadata().getFirst("Content-Type")); assertEquals("callback({\"Book\":{\"id\":123,\"name\":\"CXF in Action\"}});",IOUtils.readStringFromStream((InputStream)r.getEntity())); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetDefaultBookMatrixParam() throws Exception { String endpointAddress="http://localhost:" + PORT + "/the/bookstore/2/"; WebClient wc=WebClient.create(endpointAddress); wc.matrix("a","b"); wc.accept("application/json"); WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(1000000L); Book book=wc.get(Book.class); assertEquals(123L,book.getId()); assertEquals("Defaultb",book.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookLink() throws Exception { String address="http://localhost:" + PORT + "/the/bookstore/link"; WebClient wc=WebClient.create(address); Response r=wc.get(); Link l=r.getLink("self"); assertEquals(";rel=\"self\"",l.toString()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookXsiType() throws Exception { String address="http://localhost:" + PORT + "/the/thebooksxsi/bookstore/books/xsitype"; WebClient wc=WebClient.create(address); WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(10000000); wc.accept("application/xml"); Book book=wc.get(Book.class); assertEquals("SuperBook",book.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookXSLTHtml() throws Exception { String endpointAddress="http://localhost:" + PORT + "/the/thebooks5/bookstore/books/xslt"; WebClient wc=WebClient.create(endpointAddress); wc.accept("application/xhtml+xml").path(666).matrix("name2",2).query("name","Action - "); XMLSource source=wc.get(XMLSource.class); source.setBuffering(); Map namespaces=new HashMap(); namespaces.put("xhtml","http://www.w3.org/1999/xhtml"); Book2 b=source.getNode("xhtml:html/xhtml:body/xhtml:ul/xhtml:Book",namespaces,Book2.class); assertEquals(666,b.getId()); assertEquals("CXF in Action - 2",b.getName()); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAddInvalidBookDuplicateElementJson() throws Exception { WebClient wc=WebClient.create("http://localhost:" + PORT + "/the/bookstore/books/convert"); wc.type("application/json"); InputStream is=getClass().getResourceAsStream("resources/add_book2json_duplicate.txt"); assertNotNull(is); Response r=wc.post(is); assertEquals(400,r.getStatus()); String content=IOUtils.readStringFromStream((InputStream)r.getEntity()); assertTrue(content,content.contains("Invalid content was found starting with element")); }

APIUtilityVerifier InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testReaderWriterFromJaxrsFilters() throws Exception { String endpointAddress="http://localhost:" + PORT + "/the/thebooksWithStax/bookstore/books/convert2/123"; WebClient wc=WebClient.create(endpointAddress); wc.type("application/xml").accept("application/xml"); Book2 b=new Book2(); b.setId(777L); b.setName("CXF - 777"); Book2 b2=wc.invoke("PUT",b,Book2.class); assertNotSame(b,b2); assertEquals(777,b2.getId()); assertEquals("CXF - 777",b2.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookById() throws Exception { String endpointAddress="http://localhost:" + PORT + "/the/bookstore/2/123"; WebClient wc=WebClient.create(endpointAddress); wc.accept("application/json"); Book book=wc.get(Book.class); assertEquals(123L,book.getId()); assertEquals("Id",book.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetBookUserResourceFromProxy() throws Exception { String endpointAddress="http://localhost:" + PORT + "/the/thebooks6"; BookStoreNoAnnotations bStore=JAXRSClientFactory.createFromModel(endpointAddress,BookStoreNoAnnotations.class,"classpath:/org/apache/cxf/systest/jaxrs/resources/resources.xml",null); Book b=bStore.getBook(123L); assertNotNull(b); assertEquals(123L,b.getId()); assertEquals("CXF in Action",b.getName()); ChapterNoAnnotations proxy=bStore.getBookChapter(123L); ChapterNoAnnotations c=proxy.getItself(); assertNotNull(c); assertEquals(1,c.getId()); assertEquals("chapter 1",c.getTitle()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testBookDepthExceededXML() throws Exception { String endpointAddress="http://localhost:" + PORT + "/the/thebooks9/depth"; WebClient wc=WebClient.create(endpointAddress); Response r=wc.post(new Book("CXF",123L)); assertEquals(413,r.getStatus()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testBookDepthExceededXMLStax() throws Exception { String endpointAddress="http://localhost:" + PORT + "/the/thebooks9stax/depth"; WebClient wc=WebClient.create(endpointAddress); Response r=wc.post(new Book("CXF",123L)); assertEquals(413,r.getStatus()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetGenericBook() throws Exception { String baseAddress="http://localhost:" + PORT + "/the/thebooks8/books"; WebClient wc=WebClient.create(baseAddress); WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(10000000); Long id=wc.type("application/xml").accept("text/plain").post(new Book("CXF",1L),Long.class); assertEquals(new Long(1),id); Book book=wc.replaceHeader("Accept","application/xml").query("id",1L).get(Book.class); assertEquals("CXF",book.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookXSLTXml() throws Exception { String endpointAddress="http://localhost:" + PORT + "/the/thebooks5/bookstore/books/xslt"; WebClient wc=WebClient.create(endpointAddress); wc.accept("application/xml").path(666).matrix("name2",2).query("name","Action - "); Book b=wc.get(Book.class); assertEquals(666,b.getId()); assertEquals("CXF in Action - 2",b.getName()); }

APIUtilityVerifier InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testReaderWriterFromInterceptors() throws Exception { String endpointAddress="http://localhost:" + PORT + "/the/thebooksWithStax/bookstore/books/convert"; WebClient wc=WebClient.create(endpointAddress); wc.type("application/xml").accept("application/xml"); Book2 b=new Book2(); b.setId(777L); b.setName("CXF - 777"); Book2 b2=wc.invoke("POST",b,Book2.class); assertNotSame(b,b2); assertEquals(777,b2.getId()); assertEquals("CXF - 777",b2.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetDefaultBook() throws Exception { String endpointAddress="http://localhost:" + PORT + "/the/bookstore"; WebClient wc=WebClient.create(endpointAddress); wc.accept("application/json"); Book book=wc.get(Book.class); assertEquals(123L,book.getId()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testGetBookAsArray() throws Exception { URL url=new URL("http://localhost:" + PORT + "/the/bookstore/books/list/123"); URLConnection connect=url.openConnection(); connect.addRequestProperty("Accept","application/json"); InputStream in=connect.getInputStream(); assertEquals("{\"Books\":{\"books\":[{\"id\":123,\"name\":\"CXF in Action\"}]}}",getStringFromInputStream(in)); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookWithEncodedSemicolon() throws Exception { String endpointAddress="http://localhost:" + PORT + "/the/thebooks/bookstore/semicolon%3B"; WebClient client=WebClient.create(endpointAddress); Book book=client.get(Book.class); assertEquals(333L,book.getId()); assertEquals(";",book.getName()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetWadlFromWadlLocation() throws Exception { String address="http://localhost:" + PORT + "/the/generated"; WebClient client=WebClient.create(address + "/bookstore" + "?_wadl&_type=xml"); Document doc=StaxUtils.read(new InputStreamReader(client.get(InputStream.class),StandardCharsets.UTF_8)); List resources=checkWadlResourcesInfo(doc,address,"/schemas/book.xsd",2); assertEquals("",resources.get(0).getAttribute("type")); String type=resources.get(1).getAttribute("type"); String resourceTypeAddress=address + "/bookstoreImportResourceType.wadl#bookstoreType"; assertEquals(resourceTypeAddress,type); checkSchemas(address,"/schemas/book.xsd","/schemas/chapter.xsd","include"); checkSchemas(address,"/schemas/chapter.xsd",null,null); checkWadlResourcesType(address,resourceTypeAddress,"/schemas/book.xsd"); String templateRef=null; NodeList nd=doc.getChildNodes(); for (int i=0; i < nd.getLength(); i++) { Node n=nd.item(i); if (n.getNodeType() == Document.PROCESSING_INSTRUCTION_NODE) { String piData=((ProcessingInstruction)n).getData(); int hRefStart=piData.indexOf("href=\""); if (hRefStart > 0) { int hRefEnd=piData.indexOf("\"",hRefStart + 6); templateRef=piData.substring(hRefStart + 6,hRefEnd); } } } assertNotNull(templateRef); WebClient client2=WebClient.create(templateRef); WebClient.getConfig(client2).getHttpConduit().getClient().setReceiveTimeout(1000000L); String template=client2.get(String.class); assertNotNull(template); assertTrue(template.indexOf("

APIUtilityVerifier EqualityVerifier 
@Test public void testGetBookText() throws Exception { final String address="http://localhost:" + PORT + "/the/thebooks/bookstore/books/text"; WebClient wc=WebClient.create(address).accept("text/*"); assertEquals(406,wc.get().getStatus()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testBookDepthExceededXMLDom() throws Exception { String endpointAddress="http://localhost:" + PORT + "/the/thebooks9/depth-dom"; WebClient wc=WebClient.create(endpointAddress); Response r=wc.post(new Book("CXF",123L)); assertEquals(413,r.getStatus()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testGetBookJsonpJackson() throws Exception { String url="http://localhost:" + PORT + "/bus/jsonp2/books/123"; WebClient client=WebClient.create(url); WebClient.getConfig(client).getHttpConduit().getClient().setReceiveTimeout(10000000); client.accept("application/json, application/x-javascript"); client.query("_jsonp","callback"); Response r=client.get(); assertEquals("application/x-javascript",r.getMetadata().getFirst("Content-Type")); String response=IOUtils.readStringFromStream((InputStream)r.getEntity()); assertTrue(response.startsWith("callback({\"class\":\"org.apache.cxf.systest.jaxrs.Book\",")); assertTrue(response.endsWith("});")); assertTrue(response.contains("\"id\":123")); assertTrue(response.contains("\"name\":\"CXF in Action\"")); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetDefaultBook2() throws Exception { String endpointAddress="http://localhost:" + PORT + "/the/bookstore/2/"; WebClient wc=WebClient.create(endpointAddress); wc.accept("application/json"); Book book=wc.get(Book.class); assertEquals(123L,book.getId()); assertEquals("Default",book.getName()); }

Class: org.apache.cxf.systest.jaxrs.JAXRSClientServerStreamingTest

InternalCallVerifier EqualityVerifier 
@Test public void testGetBook123Fail() throws Exception { WebClient wc=WebClient.create("http://localhost:" + PORT + "/bookstore/books/text/xml/123"); wc.accept("text/xml"); wc.header("fail-write","yes"); Response r=wc.get(); assertEquals(500,r.getStatus()); }

Class: org.apache.cxf.systest.jaxrs.JAXRSClientServerThrottledTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookOK() throws Exception { String address="http://localhost:" + PORT + "/bookstore/books/query/default"; WebClient wc=WebClient.create(address,"alice","password",null); Response r=wc.get(); assertEquals(200,r.getStatus()); assertEquals(123L,r.readEntity(Book.class).getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookRetryAfter() throws Exception { String address="http://localhost:" + PORT + "/bookstore/books/query/default"; WebClient wc=WebClient.create(address); Response r=wc.get(); assertEquals(503,r.getStatus()); assertEquals("2",r.getHeaderString("Retry-After")); }

Class: org.apache.cxf.systest.jaxrs.JAXRSClientServerUserResourceDefaultTest

InternalCallVerifier EqualityVerifier 
@Test public void testEchoBookDefault() throws Exception { WebClient wc=WebClient.create("http://localhost:" + PORT + "/default/echobookdefault"); Book b=wc.type("application/xml").accept("application/xml").post(new Book("echo",444L),Book.class); assertEquals("echo",b.getName()); assertEquals(444L,b.getId()); }

InternalCallVerifier EqualityVerifier 
@Test public void testEchoBook() throws Exception { WebClient wc=WebClient.create("http://localhost:" + PORT + "/default/echobook"); Book b=wc.type("application/xml").accept("application/xml").post(new Book("echo",333L),Book.class); assertEquals("echo",b.getName()); assertEquals(333L,b.getId()); }

Class: org.apache.cxf.systest.jaxrs.JAXRSContinuationsServlet3Test

EqualityVerifier 
@Test public void testSuspendSetTimeoutt() throws Exception { final String base="http://localhost:" + getPort() + "/async/resource2/"; Future suspend=invokeRequest(base + "suspend"); Thread t=new Thread(new Runnable(){ public void run(){ Future timeout=invokeRequest(base + "setTimeOut"); try { assertString(timeout,"true"); } catch ( Exception ex) { ex.printStackTrace(); } } } ); t.start(); t.join(); assertEquals(503,suspend.get().getStatus()); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetBookUnmappedFromFilter() throws Exception { WebClient wc=WebClient.create("http://localhost:" + getPort() + getBaseAddress()+ "/books/unmappedFromFilter"); wc.accept("text/plain"); Response r=wc.get(); assertEquals(500,r.getStatus()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testLostThrowFromSuspendedCall() throws Exception { String base="http://localhost:" + getPort() + "/async/resource/"; Future suspend=invokeRequest(base + "suspendthrow"); Response response=suspend.get(10,TimeUnit.SECONDS); assertEquals(502,response.getStatus()); }

Class: org.apache.cxf.systest.jaxrs.JAXRSDataBindingTest

InternalCallVerifier EqualityVerifier 
@Test public void testGetBookAegis() throws Exception { WebClient client=WebClient.create("http://localhost:" + PORT + "/databinding/aegis/bookstore/books/123",Collections.singletonList(new AegisElementProvider())); Book book=client.accept("application/xml").get(Book.class); assertEquals(123L,book.getId()); assertEquals("CXF in Action",book.getName()); }

InternalCallVerifier EqualityVerifier 
@Test public void testSDOStructureJSON() throws Exception { JAXRSClientFactoryBean bean=new JAXRSClientFactoryBean(); DataBinding db=new SDODataBinding(); bean.setDataBinding(db); DataBindingJSONProvider provider=new DataBindingJSONProvider(); provider.setNamespaceMap(Collections.singletonMap("http://apache.org/structure/types","p0")); provider.setDataBinding(db); bean.setProvider(provider); bean.setAddress("http://localhost:" + PORT + "/databinding/sdo"); bean.setResourceClass(SDOResource.class); List> list=new ArrayList>(); list.add(new LoggingInInterceptor()); bean.setInInterceptors(list); SDOResource client=bean.create(SDOResource.class); WebClient.client(client).accept("application/json"); Structure struct=client.getStructure(); assertEquals("sdo",struct.getText()); assertEquals(123.5,struct.getDbl(),0.01); assertEquals(3,struct.getInt()); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetBookJIBX() throws Exception { JAXRSClientFactoryBean bean=new JAXRSClientFactoryBean(); bean.setDataBinding(new JibxDataBinding()); bean.setAddress("http://localhost:" + PORT + "/databinding/jibx"); bean.setResourceClass(JibxResource.class); JibxResource client=bean.create(JibxResource.class); org.apache.cxf.systest.jaxrs.codegen.jibx.Book b=client.getBook(); assertEquals("JIBX",b.getName()); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetBookJAXB() throws Exception { WebClient client=WebClient.create("http://localhost:" + PORT + "/databinding/jaxb/bookstore/books/123"); Book book=client.accept("application/xml").get(Book.class); assertEquals(123L,book.getId()); assertEquals("CXF in Action",book.getName()); }

Class: org.apache.cxf.systest.jaxrs.JAXRSLocalTransportTest

InternalCallVerifier EqualityVerifier 
@Test public void testWebClientDirectDispatchBookType() throws Exception { WebClient localClient=WebClient.create("local://books",Collections.singletonList(new JacksonJsonProvider())); WebClient.getConfig(localClient).getRequestContext().put(LocalConduit.DIRECT_DISPATCH,Boolean.TRUE); localClient.path("bookstore/booktype"); BookType book=localClient.get(BookType.class); assertEquals(124L,book.getId()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testProxyEmptyResponseDirectDispatch() throws Exception { BookStore localProxy=JAXRSClientFactory.create("local://books",BookStore.class); WebClient.getConfig(localProxy).getRequestContext().put(LocalConduit.DIRECT_DISPATCH,"true"); assertNull(localProxy.getEmptyBook()); assertEquals(204,WebClient.client(localProxy).getResponse().getStatus()); }

InternalCallVerifier EqualityVerifier 
@Test public void testProxyPipedDispatchGet() throws Exception { BookStore localProxy=JAXRSClientFactory.create("local://books",BookStore.class); Book book=localProxy.getBook("123"); assertEquals(123L,book.getId()); }

InternalCallVerifier EqualityVerifier 
@Test public void testProxyPipedDispatchGetBookType() throws Exception { BookStore localProxy=JAXRSClientFactory.create("local://books",BookStore.class,Collections.singletonList(new JacksonJsonProvider())); BookType book=localProxy.getBookType(); assertEquals(124L,book.getId()); }

InternalCallVerifier EqualityVerifier 
@Test public void testSubresourceProxyDirectDispatchGet() throws Exception { BookStore localProxy=JAXRSClientFactory.create("local://books",BookStore.class); WebClient.getConfig(localProxy).getRequestContext().put(LocalConduit.DIRECT_DISPATCH,"true"); Book bookSubProxy=localProxy.getBookSubResource("123"); Book book=bookSubProxy.retrieveState(); assertEquals(123L,book.getId()); }

InternalCallVerifier EqualityVerifier 
@Test public void testProxyServerOutFault() throws Exception { BookStore localProxy=JAXRSClientFactory.create("local://books",BookStore.class); Response r=localProxy.outfault(); assertEquals(403,r.getStatus()); }

InternalCallVerifier EqualityVerifier 
@Test public void testProxyServerInFaultMapped() throws Exception { BookStore localProxy=JAXRSClientFactory.create("local://books",BookStore.class); Response r=localProxy.infault(); assertEquals(401,r.getStatus()); }

InternalCallVerifier EqualityVerifier 
@Test public void testProxyWithQuery() throws Exception { BookStore localProxy=JAXRSClientFactory.create("local://books",BookStore.class); WebClient.getConfig(localProxy).getRequestContext().put(LocalConduit.DIRECT_DISPATCH,Boolean.TRUE); Book book=localProxy.getBookByURLQuery(new String[]{"1","2","3"}); assertEquals(123L,book.getId()); }

InternalCallVerifier EqualityVerifier 
@Test public void testProxyServerOutFaultDirectDispacth() throws Exception { BookStore localProxy=JAXRSClientFactory.create("local://books",BookStore.class); WebClient.getConfig(localProxy).getRequestContext().put(LocalConduit.DIRECT_DISPATCH,"true"); Response r=localProxy.outfault(); assertEquals(403,r.getStatus()); }

InternalCallVerifier EqualityVerifier 
@Test public void testWebClientPipedDispatch() throws Exception { WebClient localClient=WebClient.create("local://books"); localClient.accept("text/xml"); localClient.path("bookstore/books"); Book book=localClient.post(new Book("New",124L),Book.class); assertEquals(124L,book.getId()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testProxyDirectDispatchPostWithGzip() throws Exception { BookStore localProxy=JAXRSClientFactory.create("local://books",BookStore.class); WebClient.getConfig(localProxy).getRequestContext().put(LocalConduit.DIRECT_DISPATCH,Boolean.TRUE); Response response=localProxy.addBook(new Book("New",124L)); assertEquals(200,response.getStatus()); assertTrue(response.getMetadata().getFirst("Location") instanceof URI); }

InternalCallVerifier EqualityVerifier 
@Test public void testProxyPipedDispatchPost() throws Exception { BookStoreSpring localProxy=JAXRSClientFactory.create("local://books",BookStoreSpring.class); Book response=localProxy.convertBook(new Book2("New",124L)); assertEquals(124L,response.getId()); }

InternalCallVerifier EqualityVerifier 
@Test public void testProxyServerInFaultEscaped() throws Exception { BookStore localProxy=JAXRSClientFactory.create("local://books",BookStore.class); Response r=localProxy.infault2(); assertEquals(500,r.getStatus()); }

InternalCallVerifier EqualityVerifier 
@Test public void testProxyServerInFaultDirectDispatch() throws Exception { BookStore localProxy=JAXRSClientFactory.create("local://books",BookStore.class); WebClient.getConfig(localProxy).getRequestContext().put(LocalConduit.DIRECT_DISPATCH,"true"); WebClient.getConfig(localProxy).getInFaultInterceptors().add(new TestFaultInInterceptor()); Response r=localProxy.infault2(); assertEquals(500,r.getStatus()); }

InternalCallVerifier EqualityVerifier 
@Test public void testWebClientDirectDispatch() throws Exception { WebClient localClient=WebClient.create("local://books"); WebClient.getConfig(localClient).getRequestContext().put(LocalConduit.DIRECT_DISPATCH,Boolean.TRUE); localClient.path("bookstore/books/123"); Book book=localClient.get(Book.class); assertEquals(123L,book.getId()); }

InternalCallVerifier EqualityVerifier 
@Test public void testProxyDirectDispatchPost() throws Exception { BookStoreSpring localProxy=JAXRSClientFactory.create("local://books",BookStoreSpring.class); WebClient.getConfig(localProxy).getRequestContext().put(LocalConduit.DIRECT_DISPATCH,Boolean.TRUE); Book response=localProxy.convertBook(new Book2("New",124L)); assertEquals(124L,response.getId()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testProxyEmtpyResponse() throws Exception { BookStore localProxy=JAXRSClientFactory.create("local://books",BookStore.class); assertNull(localProxy.getEmptyBook()); assertEquals(204,WebClient.client(localProxy).getResponse().getStatus()); }

Class: org.apache.cxf.systest.jaxrs.JAXRSLoggingAtomPullSpringTest

EqualityVerifier 
@Test public void testPagedFeedWithReadWriteStorage() throws Exception { WebClient wc=WebClient.create("http://localhost:" + PORT + "/resource3/storage"); wc.path("/log").get(); Thread.sleep(3000); verifyStoragePages("http://localhost:" + PORT + "/atom3/logs","next","Resource3","theStorageLogger",false); List list=Storage.getRecords(); assertEquals(4,list.size()); verifyStoragePages("http://localhost:" + PORT + "/atom3/logs","next","Resource3","theStorageLogger",false); verifyStoragePages("http://localhost:" + PORT + "/atom3/logs/2","previous","Resource3","theStorageLogger",false); }

Class: org.apache.cxf.systest.jaxrs.JAXRSLoggingAtomPushSpringTest

EqualityVerifier 
@Test public void testEntriesWithLogRecordsOneEntry() throws Exception { WebClient wc=WebClient.create("http://localhost:" + PORT + "/entries"); wc.path("/log").get(); Thread.sleep(3000); List elements=Resource3.getElements(); assertEquals(8,elements.size()); resetCounters(); for ( Entry e : elements) { updateCounters(readLogRecord(e.getContent()),"Resource3"); } verifyCounters(); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testManyEntries() throws Exception { WebClient wc=WebClient.create("http://localhost:" + PORT + "/entriesMany"); wc.path("/log").get(); Thread.sleep(3000); List elements=Resource4.getElements(); assertEquals(4,elements.size()); resetCounters(); for ( Entry e : elements) { LogRecords records=readLogRecords(e.getContent()); List list=records.getLogRecords(); assertNotNull(list); assertEquals(2,list.size()); for ( org.apache.cxf.management.web.logging.LogRecord record : list) { updateCounters(record,"Resource4"); } } verifyCounters(); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testFeedsWithLogRecordsExtension() throws Exception { WebClient wc=WebClient.create("http://localhost:" + PORT + "/extensions"); wc.path("/log").get(); Thread.sleep(3000); List elements=Resource5.getElements(); assertEquals(8,elements.size()); resetCounters(); for ( Feed feed : elements) { List entries=feed.getEntries(); assertEquals(1,entries.size()); Entry e=entries.get(0); LogRecords records=readLogRecordsExtension(e); List list=records.getLogRecords(); assertNotNull(list); assertEquals(1,list.size()); updateCounters(list.get(0),"Resource5"); } verifyCounters(); }

InternalCallVerifier EqualityVerifier 
@Test public void testFeedsWithBatchLogRecordsOneEntry() throws Exception { WebClient wc=WebClient.create("http://localhost:" + PORT + "/batch"); wc.path("/log").get(); Thread.sleep(3000); List elements=Resource2.getElements(); assertEquals(2,elements.size()); resetCounters(); for ( Feed feed : elements) { List entries=feed.getEntries(); assertEquals(4,entries.size()); for ( Entry e : entries) { updateCounters(readLogRecord(e.getContent()),"Resource2"); } } verifyCounters(); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testFeedsWithLogRecordsOneEntry() throws Exception { WebClient wc=WebClient.create("http://localhost:" + PORT + "/root"); try { wc.path("/log").get(); } catch ( Exception ex) { } Thread.sleep(3000); List elements=Resource.getElements(); assertEquals(8,elements.size()); resetCounters(); for ( Feed feed : elements) { List entries=feed.getEntries(); assertEquals(1,entries.size()); Entry e=entries.get(0); LogRecords records=readLogRecords(e.getContent()); List list=records.getLogRecords(); assertNotNull(list); assertEquals(1,list.size()); updateCounters(list.get(0),"Resource"); } verifyCounters(); }

Class: org.apache.cxf.systest.jaxrs.JAXRSLoggingAtomPushTest

EqualityVerifier 
@Test public void testPrivateLogger() throws Exception { configureLogging("resources/logging_atompush_disabled.properties"); Logger log=LogUtils.getL7dLogger(JAXRSLoggingAtomPushTest.class,null,"private-log"); Converter c=new StandardConverter(Output.FEED,Multiplicity.ONE,Format.CONTENT); Deliverer d=new WebClientDeliverer("http://localhost:" + PORT); Handler h=new AtomPushHandler(2,c,d); log.addHandler(h); log.setLevel(Level.ALL); logSixEvents(log); waitForFeeds(Resource.feeds,3); assertEquals("Different logged events count;",3,Resource.feeds.size()); }

EqualityVerifier 
@Test public void testPrivateLoggerCustomBuilders() throws Exception { configureLogging("resources/logging_atompush_disabled.properties"); Logger log=LogUtils.getL7dLogger(JAXRSLoggingAtomPushTest.class,null,"private-log"); AbstractFeedBuilder> fb=createCustomFeedBuilder(); AbstractEntryBuilder> eb=createCustomEntryBuilder(); Converter c=new StandardConverter(Output.FEED,Multiplicity.ONE,Format.CONTENT,fb,eb); Deliverer d=new WebClientDeliverer("http://localhost:" + PORT); Handler h=new AtomPushHandler(2,c,d); log.addHandler(h); log.setLevel(Level.ALL); logSixEvents(log); waitForFeeds(Resource.feeds,3); assertEquals("Different logged events count;",3,Resource.feeds.size()); }

EqualityVerifier 
@Test public void testMultiElementBatch() throws Exception { configureLogging("resources/logging_atompush_batch.properties"); logSixEvents(LogUtils.getL7dLogger(JAXRSLoggingAtomPushTest.class)); waitForFeeds(Resource.feeds,2); assertEquals("Different logged events count;",2,Resource.feeds.size()); }

EqualityVerifier 
@Test public void testOneElementBatch() throws Exception { configureLogging("resources/logging_atompush.properties"); logSixEvents(LogUtils.getL7dLogger(JAXRSLoggingAtomPushTest.class)); waitForFeeds(Resource.feeds,6); assertEquals("Different logged events count;",6,Resource.feeds.size()); }

EqualityVerifier 
@Test public void testAtomPubEntries() throws Exception { configureLogging("resources/logging_atompush_atompub.properties"); logSixEvents(LogUtils.getL7dLogger(JAXRSLoggingAtomPushTest.class)); waitForFeeds(Resource.entries,6); assertEquals("Different logged events count;",6,Resource.entries.size()); }

Class: org.apache.cxf.systest.jaxrs.JAXRSMultipartTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testAddBookJaxbJsonImageWebClientRelated2() throws Exception { String address="http://localhost:" + PORT + "/bookstore/books/jaxbimagejson"; WebClient client=WebClient.create(address); WebClient.getConfig(client).getOutInterceptors().add(new LoggingOutInterceptor()); WebClient.getConfig(client).getInInterceptors().add(new LoggingInInterceptor()); client.type("multipart/mixed").accept("multipart/mixed"); Book jaxb=new Book("jaxb",1L); Book json=new Book("json",2L); InputStream is1=getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/java.jpg"); Map objects=new LinkedHashMap(); MultivaluedMap headers=new MetadataMap(); headers.putSingle("Content-Type","application/xml"); headers.putSingle("Content-ID","theroot"); headers.putSingle("Content-Transfer-Encoding","customxml"); Attachment attJaxb=new Attachment(headers,jaxb); headers=new MetadataMap(); headers.putSingle("Content-Type","application/json"); headers.putSingle("Content-ID","thejson"); headers.putSingle("Content-Transfer-Encoding","customjson"); Attachment attJson=new Attachment(headers,json); headers=new MetadataMap(); headers.putSingle("Content-Type","application/octet-stream"); headers.putSingle("Content-ID","theimage"); headers.putSingle("Content-Transfer-Encoding","customstream"); Attachment attIs=new Attachment(headers,is1); objects.put(MediaType.APPLICATION_XML,attJaxb); objects.put(MediaType.APPLICATION_JSON,attJson); objects.put(MediaType.APPLICATION_OCTET_STREAM,attIs); Collection coll=client.postAndGetCollection(objects,Attachment.class); List result=new ArrayList(coll); Book jaxb2=readBookFromInputStream(result.get(0).getDataHandler().getInputStream()); assertEquals("jaxb",jaxb2.getName()); assertEquals(1L,jaxb2.getId()); Book json2=readJSONBookFromInputStream(result.get(1).getDataHandler().getInputStream()); assertEquals("json",json2.getName()); assertEquals(2L,json2.getId()); InputStream is2=result.get(2).getDataHandler().getInputStream(); byte[] image1=IOUtils.readBytesFromStream(getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/java.jpg")); byte[] image2=IOUtils.readBytesFromStream(is2); assertTrue(Arrays.equals(image1,image2)); }

InternalCallVerifier EqualityVerifier 
@Test public void testAddBookAsJAXBJSONProxy() throws Exception { MultipartStore store=JAXRSClientFactory.create("http://localhost:" + PORT,MultipartStore.class); Book b=store.addBookJaxbJsonWithConsumes(new Book2("CXF in Action",1L),new Book("CXF in Action - 2",2L)); assertEquals(124L,b.getId()); assertEquals("CXF in Action - 2",b.getName()); }

EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAddBookJaxbJsonImageWebClientRelated() throws Exception { Map params=doTestAddBookJaxbJsonImageWebClient("multipart/related"); assertEquals(3,params.size()); assertNotNull(params.get("boundary")); assertNotNull(params.get("type")); assertNotNull(params.get("start")); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testUploadImageFromForm() throws Exception { InputStream is1=getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/java.jpg"); String address="http://localhost:" + PORT + "/bookstore/books/formimage"; WebClient client=WebClient.create(address); HTTPConduit conduit=WebClient.getConfig(client).getHttpConduit(); conduit.getClient().setReceiveTimeout(1000000); conduit.getClient().setConnectionTimeout(1000000); client.type("multipart/form-data").accept("multipart/form-data"); ContentDisposition cd=new ContentDisposition("attachment;filename=java.jpg"); MultivaluedMap headers=new MetadataMap(); headers.putSingle("Content-ID","image"); headers.putSingle("Content-Disposition",cd.toString()); headers.putSingle("Content-Location","http://host/bar"); headers.putSingle("custom-header","custom"); Attachment att=new Attachment(is1,headers); MultipartBody body=new MultipartBody(att); MultipartBody body2=client.post(body,MultipartBody.class); InputStream is2=body2.getRootAttachment().getDataHandler().getInputStream(); byte[] image1=IOUtils.readBytesFromStream(getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/java.jpg")); byte[] image2=IOUtils.readBytesFromStream(is2); assertTrue(Arrays.equals(image1,image2)); ContentDisposition cd2=body2.getRootAttachment().getContentDisposition(); assertEquals("attachment;filename=java.jpg",cd2.toString()); assertEquals("java.jpg",cd2.getParameter("filename")); assertEquals("http://host/location",body2.getRootAttachment().getHeader("Content-Location")); }

EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAddBookJaxbJsonImageWebClientMixed() throws Exception { Map params=doTestAddBookJaxbJsonImageWebClient("multipart/mixed"); assertEquals(1,params.size()); assertNotNull(params.get("boundary")); }

EqualityVerifier 
@Test public void testBookAsMassiveAttachment() throws Exception { int orig=countTempFiles(); String address="http://localhost:" + PORT + "/bookstore/books/attachments"; InputStream is=getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/attachmentData"); PushbackInputStream buf=new PushbackInputStream(is,1024 * 20){ int bcount=-1; @Override public int read( byte b[], int offset, int len) throws IOException { if (bcount >= 0 && bcount < 1024 * 50) { for (int x=0; x < len; x++) { b[offset + x]=(byte)x; } bcount+=len; return len; } int i=super.read(b,offset,len); for (int x=0; x < i - 5; x++) { if (b[x + offset] == '*' && b[x + offset + 1] == '*' && b[x + offset + 2] == 'D' && b[x + offset + 3] == '*' && b[x + offset + 4] == '*') { super.unread(b,x + offset + 5,i - x - 5); i=x; bcount=0; } } return i; } } ; doAddBook("multipart/related",address,buf,413); assertEquals(orig,countTempFiles()); }

InternalCallVerifier EqualityVerifier 
@Test public void testMultipartRequestNoBody() throws Exception { PostMethod post=new PostMethod("http://localhost:" + PORT + "/bookstore/books/image"); String ct="multipart/mixed"; post.setRequestHeader("Content-Type",ct); HttpClient httpclient=new HttpClient(); try { int result=httpclient.executeMethod(post); assertEquals(400,result); } finally { post.releaseConnection(); } }

InternalCallVerifier EqualityVerifier 
@Test public void testUseProxyToAddBookAndSimpleParts() throws Exception { MultipartStore store=JAXRSClientFactory.create("http://localhost:" + PORT,MultipartStore.class); HTTPConduit conduit=WebClient.getConfig(store).getHttpConduit(); conduit.getClient().setReceiveTimeout(1000000); Book b=store.testAddBookAndSimpleParts(new Book("CXF in Action",124L),"1",2); assertEquals(124L,b.getId()); assertEquals("CXF in Action - 12",b.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testAddGetJaxbBooksWebClient() throws Exception { String address="http://localhost:" + PORT + "/bookstore/books/jaxbonly"; WebClient client=WebClient.create(address); client.type("multipart/mixed;type=application/xml").accept("multipart/mixed"); Book b=new Book("jaxb",1L); Book b2=new Book("jaxb2",2L); List books=new ArrayList(); books.add(b); books.add(b2); Collection coll=client.postAndGetCollection(books,Book.class); List result=new ArrayList(coll); Book jaxb=result.get(0); assertEquals("jaxb",jaxb.getName()); assertEquals(1L,jaxb.getId()); Book jaxb2=result.get(1); assertEquals("jaxb2",jaxb2.getName()); assertEquals(2L,jaxb2.getId()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testAddBookJaxbJsonImageAttachments() throws Exception { String address="http://localhost:" + PORT + "/bookstore/books/jaxbimagejson"; WebClient client=WebClient.create(address); client.type("multipart/mixed").accept("multipart/mixed"); Book jaxb=new Book("jaxb",1L); Book json=new Book("json",2L); InputStream is1=getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/java.jpg"); List objects=new ArrayList(); objects.add(new Attachment("",MediaType.APPLICATION_XML,jaxb)); objects.add(new Attachment("thejson",MediaType.APPLICATION_JSON,json)); objects.add(new Attachment("theimage",MediaType.APPLICATION_OCTET_STREAM,is1)); Collection coll=client.postAndGetCollection(objects,Attachment.class); List result=new ArrayList(coll); Book jaxb2=readBookFromInputStream(result.get(0).getDataHandler().getInputStream()); assertEquals("jaxb",jaxb2.getName()); assertEquals(1L,jaxb2.getId()); Book json2=readJSONBookFromInputStream(result.get(1).getDataHandler().getInputStream()); assertEquals("json",json2.getName()); assertEquals(2L,json2.getId()); InputStream is2=result.get(2).getDataHandler().getInputStream(); byte[] image1=IOUtils.readBytesFromStream(getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/java.jpg")); byte[] image2=IOUtils.readBytesFromStream(is2); assertTrue(Arrays.equals(image1,image2)); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testUploadFileWithSemicolonName() throws Exception { String address="http://localhost:" + PORT + "/bookstore/books/file/semicolon"; WebClient client=WebClient.create(address); client.type("multipart/form-data").accept("text/plain"); ContentDisposition cd=new ContentDisposition("attachment;name=\"a\";filename=\"a;txt\""); MultivaluedMap headers=new MetadataMap(); headers.putSingle("Content-Disposition",cd.toString()); Attachment att=new Attachment(new ByteArrayInputStream("file name with semicolon".getBytes()),headers); MultipartBody body=new MultipartBody(att); String partContent=client.post(body,String.class); assertEquals("file name with semicolon, filename:" + "a;txt",partContent); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testAddBookWebClient(){ InputStream is1=getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/add_book.txt"); String address="http://localhost:" + PORT + "/bookstore/books/jaxb"; WebClient client=WebClient.create(address); WebClient.getConfig(client).getRequestContext().put("support.type.as.multipart","true"); client.type("multipart/related;type=text/xml").accept("text/xml"); Book book=client.post(is1,Book.class); assertEquals("CXF in Action - 2",book.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testNullableParamsPrimitive() throws Exception { String address="http://localhost:" + PORT + "/bookstore/books/testnullpartprimitive"; WebClient client=WebClient.create(address); client.type("multipart/form-data").accept("text/plain"); List atts=new LinkedList(); atts.add(new Attachment("somepart","text/plain","hello there")); Response r=client.postCollection(atts,Attachment.class); assertEquals(Response.Status.OK.getStatusCode(),r.getStatus()); assertEquals((Integer)0,Integer.valueOf(IOUtils.readStringFromStream((InputStream)r.getEntity()))); }

InternalCallVerifier EqualityVerifier 
@Test public void testMultipartRequestTooLarge() throws Exception { PostMethod post=new PostMethod("http://localhost:" + PORT + "/bookstore/books/image"); String ct="multipart/mixed"; post.setRequestHeader("Content-Type",ct); Part[] parts=new Part[1]; parts[0]=new FilePart("image",new ByteArrayPartSource("testfile.png",new byte[1024 * 11]),"image/png",null); post.setRequestEntity(new MultipartRequestEntity(parts,post.getParams())); HttpClient httpclient=new HttpClient(); try { int result=httpclient.executeMethod(post); assertEquals(413,result); } finally { post.releaseConnection(); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookJaxbJsonProxy() throws Exception { String address="http://localhost:" + PORT; MultipartStore client=JAXRSClientFactory.create(address,MultipartStore.class); Map map=client.getBookJaxbJson(); List result=new ArrayList(map.values()); Book jaxb=result.get(0); assertEquals("jaxb",jaxb.getName()); assertEquals(1L,jaxb.getId()); Book json=result.get(1); assertEquals("json",json.getName()); assertEquals(2L,json.getId()); String contentType=WebClient.client(client).getResponse().getMetadata().getFirst("Content-Type").toString(); MediaType mt=MediaType.valueOf(contentType); assertEquals("multipart",mt.getType()); assertEquals("mixed",mt.getSubtype()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testAddBookJsonImageStream() throws Exception { String address="http://localhost:" + PORT + "/bookstore/books/jsonimagestream"; WebClient client=WebClient.create(address); WebClient.getConfig(client).getOutInterceptors().add(new LoggingOutInterceptor()); WebClient.getConfig(client).getInInterceptors().add(new LoggingInInterceptor()); client.type("multipart/mixed").accept("multipart/mixed"); Book json=new Book("json",1L); InputStream is1=getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/java.jpg"); Map objects=new LinkedHashMap(); MultivaluedMap headers=new MetadataMap(); headers=new MetadataMap(); headers.putSingle("Content-Type","application/json"); headers.putSingle("Content-ID","thejson"); headers.putSingle("Content-Transfer-Encoding","customjson"); Attachment attJson=new Attachment(headers,json); headers=new MetadataMap(); headers.putSingle("Content-Type","application/octet-stream"); headers.putSingle("Content-ID","theimage"); headers.putSingle("Content-Transfer-Encoding","customstream"); Attachment attIs=new Attachment(headers,is1); objects.put(MediaType.APPLICATION_JSON,attJson); objects.put(MediaType.APPLICATION_OCTET_STREAM,attIs); Collection coll=client.postAndGetCollection(objects,Attachment.class); List result=new ArrayList(coll); assertEquals(2,result.size()); Book json2=readJSONBookFromInputStream(result.get(0).getDataHandler().getInputStream()); assertEquals("json",json2.getName()); assertEquals(1L,json2.getId()); InputStream is2=result.get(1).getDataHandler().getInputStream(); byte[] image1=IOUtils.readBytesFromStream(getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/java.jpg")); byte[] image2=IOUtils.readBytesFromStream(is2); assertTrue(Arrays.equals(image1,image2)); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testUploadImageFromForm2() throws Exception { File file=new File(getClass().getResource("/org/apache/cxf/systest/jaxrs/resources/java.jpg").toURI().getPath()); String address="http://localhost:" + PORT + "/bookstore/books/formimage2"; WebClient client=WebClient.create(address); client.type("multipart/form-data").accept("multipart/form-data"); WebClient.getConfig(client).getRequestContext().put("support.type.as.multipart","true"); MultipartBody body2=client.post(file,MultipartBody.class); InputStream is2=body2.getRootAttachment().getDataHandler().getInputStream(); byte[] image1=IOUtils.readBytesFromStream(getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/java.jpg")); byte[] image2=IOUtils.readBytesFromStream(is2); assertTrue(Arrays.equals(image1,image2)); ContentDisposition cd2=body2.getRootAttachment().getContentDisposition(); assertEquals("form-data;name=file;filename=java.jpg",cd2.toString()); assertEquals("java.jpg",cd2.getParameter("filename")); }

EqualityVerifier 
@Test public void testNullPartProxy() throws Exception { MultipartStore store=JAXRSClientFactory.create("http://localhost:" + PORT,MultipartStore.class); assertEquals("nobody home2",store.testNullParts("value1",null)); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testXopWebClient() throws Exception { String address="http://localhost:" + PORT + "/bookstore/xop"; JAXRSClientFactoryBean bean=new JAXRSClientFactoryBean(); bean.setAddress(address); bean.setProperties(Collections.singletonMap(org.apache.cxf.message.Message.MTOM_ENABLED,(Object)"true")); WebClient client=bean.createWebClient(); WebClient.getConfig(client).getInInterceptors().add(new LoggingInInterceptor()); WebClient.getConfig(client).getOutInterceptors().add(new LoggingOutInterceptor()); WebClient.getConfig(client).getRequestContext().put("support.type.as.multipart","true"); client.type("multipart/related").accept("multipart/related"); XopType xop=new XopType(); xop.setName("xopName"); InputStream is=getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/book.xsd"); byte[] data=IOUtils.readBytesFromStream(is); xop.setAttachinfo(new DataHandler(new ByteArrayDataSource(data,"application/octet-stream"))); xop.setAttachInfoRef(new DataHandler(new ByteArrayDataSource(data,"application/octet-stream"))); String bookXsd=IOUtils.readStringFromStream(getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/book.xsd")); xop.setAttachinfo2(bookXsd.getBytes()); xop.setImage(getImage("/org/apache/cxf/systest/jaxrs/resources/java.jpg")); XopType xop2=client.post(xop,XopType.class); String bookXsdOriginal=IOUtils.readStringFromStream(getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/book.xsd")); String bookXsd2=IOUtils.readStringFromStream(xop2.getAttachinfo().getInputStream()); assertEquals(bookXsdOriginal,bookXsd2); String bookXsdRef=IOUtils.readStringFromStream(xop2.getAttachInfoRef().getInputStream()); assertEquals(bookXsdOriginal,bookXsdRef); String ctString=client.getResponse().getMetadata().getFirst("Content-Type").toString(); MediaType mt=MediaType.valueOf(ctString); Map params=mt.getParameters(); assertEquals(4,params.size()); assertNotNull(params.get("boundary")); assertNotNull(params.get("type")); assertNotNull(params.get("start")); assertNotNull(params.get("start-info")); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testBookAsRootAttachmentInputStreamReadItself() throws Exception { String address="http://localhost:" + PORT + "/bookstore/books/istream2"; WebClient wc=WebClient.create(address); wc.type("multipart/mixed;type=text/xml"); wc.accept("text/xml"); WebClient.getConfig(wc).getRequestContext().put("support.type.as.multipart","true"); Book book=wc.post(new Book("CXF in Action - 2",12345L),Book.class); assertEquals(432L,book.getId()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testGetBookJaxbJsonProxy2() throws Exception { String address="http://localhost:" + PORT; MultipartStore client=JAXRSClientFactory.create(address,MultipartStore.class); Map map=client.getBookJaxbJsonObject(); List result=new ArrayList(map.values()); assertEquals(2,result.size()); assertTrue(((Attachment)result.get(0)).getContentType().toString().contains("application/xml")); assertTrue(((Attachment)result.get(1)).getContentType().toString().contains("application/json")); }

InternalCallVerifier EqualityVerifier 
@Test public void testMultipartRequestTooLargeManyParts() throws Exception { PostMethod post=new PostMethod("http://localhost:" + PORT + "/bookstore/books/image"); String ct="multipart/mixed"; post.setRequestHeader("Content-Type",ct); Part[] parts=new Part[2]; parts[0]=new FilePart("image",new ByteArrayPartSource("testfile.png",new byte[1024 * 9]),"image/png",null); parts[1]=new FilePart("image",new ByteArrayPartSource("testfile2.png",new byte[1024 * 11]),"image/png",null); post.setRequestEntity(new MultipartRequestEntity(parts,post.getParams())); HttpClient httpclient=new HttpClient(); try { int result=httpclient.executeMethod(post); assertEquals(413,result); } finally { post.releaseConnection(); } }

InternalCallVerifier EqualityVerifier 
@Test public void testAddBookAsJAXBOnlyProxy() throws Exception { MultipartStore store=JAXRSClientFactory.create("http://localhost:" + PORT,MultipartStore.class); Book2 b=store.addBookJaxbOnlyWithConsumes(new Book2("CXF in Action",1L)); assertEquals(1L,b.getId()); assertEquals("CXF in Action",b.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookJsonProxy() throws Exception { String address="http://localhost:" + PORT; MultipartStore client=JAXRSClientFactory.create(address,MultipartStore.class); Map map=client.getBookJson(); List result=new ArrayList(map.values()); assertEquals(1,result.size()); Book json=result.get(0); assertEquals("json",json.getName()); assertEquals(1L,json.getId()); String contentType=WebClient.client(client).getResponse().getMetadata().getFirst("Content-Type").toString(); MediaType mt=MediaType.valueOf(contentType); assertEquals("multipart",mt.getType()); assertEquals("mixed",mt.getSubtype()); }

Class: org.apache.cxf.systest.jaxrs.JAXRSOverlappingDestinationsTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testAbsolutePathOneAndTwo() throws Exception { final String requestURI="http://localhost:" + PORT + "/one/bookstore/request?delay"; Callable callable=new Callable(){ public String call(){ WebClient wc=WebClient.create(requestURI); return wc.accept("text/plain").get(String.class); } } ; FutureTask task=new FutureTask(callable); ExecutorService executor=Executors.newFixedThreadPool(1); executor.execute(task); Thread.sleep(1000); Runnable runnable=new Runnable(){ public void run(){ try { testAbsolutePathTwo(); } catch ( Exception ex) { throw new RuntimeException("Concurrent testAbsolutePathTwo failed"); } } } ; new Thread(runnable).start(); Thread.sleep(2000); String path=task.get(); assertEquals("Absolute RequestURI is wrong",requestURI,path); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testAbsolutePathOneAndTwoWithLock() throws Exception { WebClient.create("http://localhost:" + PORT + "/one/bookstore/lock").accept("text/plain").get(); final String requestURI="http://localhost:" + PORT + "/one/bookstore/uris"; Callable callable=new Callable(){ public String call(){ WebClient wc=WebClient.create(requestURI); return wc.accept("text/plain").get(String.class); } } ; FutureTask task=new FutureTask(callable); ExecutorService executor=Executors.newFixedThreadPool(1); executor.execute(task); Thread.sleep(3000); WebClient wc2=WebClient.create("http://localhost:" + PORT + "/two/bookstore/unlock"); wc2.accept("text/plain").get(); String path=task.get(); assertEquals("Absolute RequestURI is wrong",requestURI,path); }

InternalCallVerifier EqualityVerifier 
@Test public void testAbsolutePathTwo() throws Exception { WebClient wc=WebClient.create("http://localhost:" + PORT + "/two/bookstore/request"); String path=wc.accept("text/plain").get(String.class); assertEquals("Absolute RequestURI is wrong",wc.getBaseURI().toString(),path); }

InternalCallVerifier EqualityVerifier 
@Test public void testAbsolutePathOne() throws Exception { WebClient wc=WebClient.create("http://localhost:" + PORT + "/one/bookstore/request"); String path=wc.accept("text/plain").get(String.class); assertEquals("Absolute RequestURI is wrong",wc.getBaseURI().toString(),path); }

Class: org.apache.cxf.systest.jaxrs.JAXRSRequestDispatcherTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetTextWelcomeFile() throws Exception { String address="http://localhost:" + PORT + "/welcome2/welcome.txt"; WebClient client=WebClient.create(address); client.accept("text/plain"); String welcome=client.get(String.class); System.out.println(welcome); assertEquals("Welcome",welcome); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookHTMLFromDefaultServlet() throws Exception { String endpointAddress="http://localhost:" + PORT + "/the/bookstore4/books/html/123"; WebClient client=WebClient.create(endpointAddress); client.accept("text/html"); WebClient.getConfig(client).getHttpConduit().getClient().setReceiveTimeout(100000000); XMLSource source=client.accept("text/html").get(XMLSource.class); Map namespaces=new HashMap(); namespaces.put("xhtml","http://www.w3.org/1999/xhtml"); namespaces.put("books","http://www.w3.org/books"); String value=source.getValue("xhtml:html/xhtml:body/xhtml:ul/books:bookTag",namespaces); assertEquals("CXF Rocks",value); }

Class: org.apache.cxf.systest.jaxrs.JAXRSServletFilterTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testServletConfigInitParam() throws Exception { String endpointAddress="http://localhost:" + PORT + "/webapp/filter/resources/servlet/config/query?name=a"; WebClient wc=WebClient.create(endpointAddress); WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(1000000L); wc.accept("text/plain"); assertEquals("avalue",wc.get(String.class)); }

Class: org.apache.cxf.systest.jaxrs.JAXRSSimpleRequestDispatcherTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetTextWelcomeFile() throws Exception { String address="http://localhost:" + PORT + "/dispatch/welcome.txt"; WebClient client=WebClient.create(address); client.accept("text/plain"); String welcome=client.get(String.class); assertEquals("Welcome",welcome); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetRedirectedBook() throws Exception { String address="http://localhost:" + PORT + "/dispatch/bookstore2/books/redirectStart"; WebClient client=WebClient.create(address); WebClient.getConfig(client).getHttpConduit().getClient().setReceiveTimeout(10000000L); client.accept("application/json"); Book book=client.get(Book.class); assertEquals("Redirect complete: /dispatch/bookstore/books/redirectComplete",book.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetRedirectedBook2() throws Exception { String address="http://localhost:" + PORT + "/dispatch/redirect/bookstore3/books/redirectStart"; WebClient client=WebClient.create(address); WebClient.getConfig(client).getHttpConduit().getClient().setReceiveTimeout(10000000L); client.accept("application/json"); Book book=client.get(Book.class); assertEquals("Redirect complete: /dispatch/redirect/bookstore/books/redirectComplete",book.getName()); }

Class: org.apache.cxf.systest.jaxrs.JAXRSSoapBookTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testPostBookTransform() throws Exception { String address="http://localhost:" + PORT + "/test/v1/rest-transform/bookstore/books"; TransformOutInterceptor out=new TransformOutInterceptor(); out.setOutTransformElements(Collections.singletonMap("{http://www.example.org/books}*","{http://www.example.org/super-books}*")); TransformInInterceptor in=new TransformInInterceptor(); Map map=new HashMap(); map.put("TheBook","{http://www.example.org/books}Book"); map.put("id","{http://www.example.org/books}id"); in.setInTransformElements(map); WebClient client=WebClient.create(address); WebClient.getConfig(client).getInInterceptors().add(in); WebClient.getConfig(client).getOutInterceptors().add(out); Book2 book=client.accept("text/xml").post(new Book2(),Book2.class); assertEquals(124L,book.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testPostGetBookFastinfosetProxy() throws Exception { JAXBElementProvider p=new JAXBElementProvider(); p.setConsumeMediaTypes(Collections.singletonList("application/fastinfoset")); p.setProduceMediaTypes(Collections.singletonList("application/fastinfoset")); BookStoreJaxrsJaxws client=JAXRSClientFactory.create("http://localhost:" + PORT + "/test/services/rest4",BookStoreSoapRestFastInfoset2.class,Collections.singletonList(p)); Book b=new Book("CXF",1L); Book b2=client.addFastinfoBook(b); assertEquals(b2.getName(),b.getName()); assertEquals(b2.getId(),b.getId()); checkFiInterceptors(WebClient.getConfig(client)); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testAddOrderFormBean() throws Exception { String baseAddress="http://localhost:" + PORT + "/test/services/rest"; BookStoreJaxrsJaxws proxy=JAXRSClientFactory.create(baseAddress,BookStoreJaxrsJaxws.class); WebClient.getConfig(proxy).getOutInterceptors().add(new LoggingOutInterceptor()); WebClient.getConfig(proxy).getInInterceptors().add(new LoggingInInterceptor()); BookSubresource bs=proxy.getBookSubresource("139"); OrderBean order=new OrderBean(); order.setId(123L); order.setWeight(100); order.setCustomerTitle(OrderBean.Title.MS); OrderBean order2=bs.addOrder(order); assertEquals(Long.valueOf(123L),Long.valueOf(order2.getId())); assertEquals(OrderBean.Title.MS,order2.getCustomerTitle()); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetBookSoap() throws Exception { String wsdlAddress="http://localhost:" + PORT + "/test/services/soap/bookservice?wsdl"; URL wsdlUrl=new URL(wsdlAddress); BookSoapService service=new BookSoapService(wsdlUrl,new QName("http://books.com","BookService")); BookStoreJaxrsJaxws store=service.getBookPort(); Book book=store.getBook(new Long(123)); assertEquals("id is wrong",book.getId(),123); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testNoBookWebClient() throws Exception { String baseAddress="http://localhost:" + PORT + "/test/services/rest"; WebClient client=WebClient.create(baseAddress); client.path("/bookstore/books/0/subresource").accept(MediaType.APPLICATION_XML_TYPE); Book b=client.get(Book.class); assertNull(b); assertEquals(204,client.getResponse().getStatus()); }

EqualityVerifier 
@Test public void testGetBook123() throws Exception { InputStream in=getHttpInputStream("http://localhost:" + PORT + "/test/services/rest/bookstore/123"); InputStream expected=getClass().getResourceAsStream("resources/expected_get_book123.txt"); assertEquals(stripXmlInstructionIfNeeded(getStringFromInputStream(expected)),stripXmlInstructionIfNeeded(getStringFromInputStream(in))); }

EqualityVerifier 
@Test public void testGetBook123ServletResponse() throws Exception { InputStream in=getHttpInputStream("http://localhost:" + PORT + "/test/services/rest/bookstore/0"); InputStream expected=getClass().getResourceAsStream("resources/expected_get_book123.txt"); assertEquals(stripXmlInstructionIfNeeded(getStringFromInputStream(expected)),stripXmlInstructionIfNeeded(getStringFromInputStream(in))); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookSubresourceParamExtensions2() throws Exception { String baseAddress="http://localhost:" + PORT + "/test/services/rest"; BookStoreJaxrsJaxws proxy=JAXRSClientFactory.create(baseAddress,BookStoreJaxrsJaxws.class); WebClient.getConfig(proxy).getOutInterceptors().add(new LoggingOutInterceptor()); BookSubresource bs=proxy.getBookSubresource("139"); BookBean bean=new BookBean("CXF Rocks",139L); bean.getComments().put(1L,"Good"); bean.getComments().put(2L,"Good"); BookBean b=bs.getTheBookQueryBean(bean); assertEquals(139,b.getId()); assertEquals("CXF Rocks",b.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookSubresourceWebClientParamExtensions() throws Exception { WebClient client=WebClient.create("http://localhost:" + PORT + "/test/services/rest"); client.type(MediaType.TEXT_PLAIN_TYPE).accept(MediaType.APPLICATION_XML_TYPE); client.path("/bookstore/books/139/subresource4/139/CXF Rocks"); Book bean=new Book("CXF Rocks",139L); Form form=new Form(); form.param("name","CXF Rocks").param("id",Long.toString(139L)); Book b=readBook((InputStream)client.matrix("",bean).query("",bean).form(form).getEntity()); assertEquals(139,b.getId()); assertEquals("CXF Rocks",b.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookSubresourceClientWithContext() throws Exception { String baseAddress="http://localhost:" + PORT + "/test/services/rest"; BookStoreJaxrsJaxws proxy=JAXRSClientFactory.create(baseAddress,BookStoreJaxrsJaxws.class); BookSubresource bs=proxy.getBookSubresource("125"); Book b=bs.getTheBookWithContext(null); assertEquals(125,b.getId()); assertEquals("CXF in Action",b.getName()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testAddFeatureToClient() throws Exception { String baseAddress="http://localhost:" + PORT + "/test/services/rest"; JAXRSClientFactoryBean bean=new JAXRSClientFactoryBean(); bean.setAddress(baseAddress); bean.setResourceClass(BookStoreJaxrsJaxws.class); TestFeature testFeature=new TestFeature(); List features=new ArrayList(); features.add(testFeature); bean.setFeatures(features); BookStoreJaxrsJaxws proxy=(BookStoreJaxrsJaxws)bean.create(); Book b=proxy.getBook(new Long("123")); assertTrue("Out Interceptor not invoked",testFeature.handleMessageOnOutInterceptorCalled()); assertTrue("In Interceptor not invoked",testFeature.handleMessageOnInInterceptorCalled()); assertEquals(123,b.getId()); assertEquals("CXF in Action",b.getName()); }

APIUtilityVerifier InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testAddGetBook123Client() throws Exception { String baseAddress="http://localhost:" + PORT + "/test/services/rest"; BookStoreJaxrsJaxws proxy=JAXRSClientFactory.create(baseAddress,BookStoreJaxrsJaxws.class); Book b=new Book(); b.setId(124); b.setName("CXF in Action - 2"); Book b2=proxy.addBook(b); assertNotSame(b,b2); assertEquals(124,b2.getId()); assertEquals("CXF in Action - 2",b2.getName()); }

APIUtilityVerifier InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testAddGetBook123WebClient() throws Exception { String baseAddress="http://localhost:" + PORT + "/test/services/rest"; WebClient client=WebClient.create(baseAddress); client.path("/bookstore/books").accept(MediaType.APPLICATION_XML_TYPE).type(MediaType.APPLICATION_XML_TYPE); Book b=new Book(); b.setId(124); b.setName("CXF in Action - 2"); Book b2=client.post(b,Book.class); assertNotSame(b,b2); assertEquals(124,b2.getId()); assertEquals("CXF in Action - 2",b2.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookWebClientForm2() throws Exception { String baseAddress="http://localhost:" + PORT + "/test/services/rest/bookstore/books/679/subresource3"; WebClient wc=WebClient.create(baseAddress); Form f=new Form(new MetadataMap()); f.param("id","679").param("name","CXF in Action - ").param("name","679"); Book b=readBook((InputStream)wc.accept("application/xml").form(f).getEntity()); assertEquals(679,b.getId()); assertEquals("CXF in Action - 679",b.getName()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testGetAll() throws Exception { URL url=new URL("http://localhost:" + PORT + "/test/services/rest2/myRestService"); URLConnection connect=url.openConnection(); connect.addRequestProperty("Accept","text/plain"); InputStream in=connect.getInputStream(); assertEquals("0",getStringFromInputStream(in)); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookSubresourceParamOrder() throws Exception { String baseAddress="http://localhost:" + PORT + "/test/services/rest"; BookStoreJaxrsJaxws proxy=JAXRSClientFactory.create(baseAddress,BookStoreJaxrsJaxws.class); BookSubresource bs=proxy.getBookSubresource("139"); Book b=bs.getTheBook5("CXF",555L); assertEquals(555,b.getId()); assertEquals("CXF",b.getName()); }

InternalCallVerifier EqualityVerifier 
@Test public void testNoBook357WebClient() throws Exception { JAXRSClientFactoryBean bean=new JAXRSClientFactoryBean(); Map properties=new HashMap(); properties.put("org.apache.cxf.http.throw_io_exceptions",Boolean.TRUE); bean.setProperties(properties); bean.setAddress("http://localhost:" + PORT + "/test/services/rest/bookstore/356"); WebClient wc=bean.createWebClient(); Response response=wc.get(); assertEquals(404,response.getStatus()); String msg=IOUtils.readStringFromStream((InputStream)response.getEntity()); assertEquals("No Book with id 356 is available",msg); }

InternalCallVerifier EqualityVerifier 
@Test public void testAddGetBookRest() throws Exception { String endpointAddress="http://localhost:" + PORT + "/test/services/rest/bookstore/books"; File input=new File(getClass().getResource("resources/add_book.txt").toURI()); PostMethod post=new PostMethod(endpointAddress); post.setRequestHeader("Content-Type","application/xml"); RequestEntity entity=new FileRequestEntity(input,"text/xml; charset=ISO-8859-1"); post.setRequestEntity(entity); HttpClient httpclient=new HttpClient(); try { int result=httpclient.executeMethod(post); assertEquals(200,result); InputStream expected=getClass().getResourceAsStream("resources/expected_add_book.txt"); assertEquals(stripXmlInstructionIfNeeded(getStringFromInputStream(expected)),stripXmlInstructionIfNeeded(post.getResponseBodyAsString())); } finally { post.releaseConnection(); } }

APIUtilityVerifier InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testGetBook123Client() throws Exception { String baseAddress="http://localhost:" + PORT + "/test/services/rest"; BookStoreJaxrsJaxws proxy=JAXRSClientFactory.create(baseAddress,BookStoreJaxrsJaxws.class); HTTPConduit conduit=(HTTPConduit)WebClient.getConfig(proxy).getConduit(); Book b=proxy.getBook(new Long("123")); assertEquals(123,b.getId()); assertEquals("CXF in Action",b.getName()); HTTPConduit conduit2=(HTTPConduit)WebClient.getConfig(proxy).getConduit(); assertSame(conduit,conduit2); conduit.getClient().setAutoRedirect(true); b=proxy.getBook(new Long("123")); assertEquals(123,b.getId()); assertEquals("CXF in Action",b.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBook123WebClientResponse() throws Exception { String baseAddress="http://localhost:" + PORT + "/test/services/rest"; WebClient client=WebClient.create(baseAddress); client.path("/bookstore/123").accept(MediaType.APPLICATION_XML_TYPE); Book b=readBook((InputStream)client.get().getEntity()); assertEquals(123,b.getId()); assertEquals("CXF in Action",b.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookSubresourceClient() throws Exception { String baseAddress="http://localhost:" + PORT + "/test/services/rest"; BookStoreJaxrsJaxws proxy=JAXRSClientFactory.create(baseAddress,BookStoreJaxrsJaxws.class); BookSubresource bs=proxy.getBookSubresource("125"); Book b=bs.getTheBook(); assertEquals(125,b.getId()); assertEquals("CXF in Action",b.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookSubresourceClientFormParam() throws Exception { String baseAddress="http://localhost:" + PORT + "/test/services/rest"; BookStoreJaxrsJaxws proxy=JAXRSClientFactory.create(baseAddress,BookStoreJaxrsJaxws.class); BookSubresource bs=proxy.getBookSubresource("679"); List parts=new ArrayList(); parts.add("CXF in Action - "); parts.add(Integer.toString(679)); Book b=bs.getTheBook3("679",parts); assertEquals(679,b.getId()); assertEquals("CXF in Action - 679",b.getName()); }

InternalCallVerifier EqualityVerifier 
@Test public void testOtherInterceptorDrainingStream() throws Exception { String baseAddress="http://localhost:" + PORT + "/test/services/rest"; JAXRSClientFactoryBean bean=new JAXRSClientFactoryBean(); bean.setAddress(baseAddress); bean.getInInterceptors().add(new TestStreamDrainInterptor()); WebClient client=bean.createWebClient(); client.path("/bookstore/123").accept(MediaType.APPLICATION_XML_TYPE); Book b=client.get(Book.class); assertEquals(123,b.getId()); assertEquals("CXF in Action",b.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testPostGetBookFastinfosetProxyInterceptors() throws Exception { JAXBElementProvider p=new JAXBElementProvider(); p.setConsumeMediaTypes(Collections.singletonList("application/fastinfoset")); p.setProduceMediaTypes(Collections.singletonList("application/fastinfoset")); BookStoreJaxrsJaxws client=JAXRSClientFactory.create("http://localhost:" + PORT + "/test/services/rest5",BookStoreSoapRestFastInfoset3.class,Collections.singletonList(p)); Book b=new Book("CXF",1L); Map props=WebClient.getConfig(client).getRequestContext(); props.put(FIStaxOutInterceptor.FI_ENABLED,Boolean.TRUE); Book b2=client.addFastinfoBook(b); assertEquals(b2.getName(),b.getName()); assertEquals(b2.getId(),b.getId()); checkFiInterceptors(WebClient.getConfig(client)); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookWebClientForm() throws Exception { String baseAddress="http://localhost:" + PORT + "/test/services/rest/bookstore/books/679/subresource3"; WebClient wc=WebClient.create(baseAddress); MultivaluedMap map=new MetadataMap(); map.putSingle("id","679"); map.add("name","CXF in Action - "); map.add("name","679"); Book b=readBook((InputStream)wc.accept("application/xml").form(map).getEntity()); assertEquals(679,b.getId()); assertEquals("CXF in Action - 679",b.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBook123XMLSource() throws Exception { String baseAddress="http://localhost:" + PORT + "/test/services/rest"; WebClient client=WebClient.create(baseAddress); client.path("/bookstore/123").accept(MediaType.APPLICATION_XML_TYPE); XMLSource source=client.get(XMLSource.class); source.setBuffering(); Book b=source.getNode("/Book",Book.class); assertEquals(123,b.getId()); assertEquals("CXF in Action",b.getName()); b=source.getNode("/Book",Book.class); assertEquals(123,b.getId()); assertEquals("CXF in Action",b.getName()); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetBookFastinfoset() throws Exception { JAXRSClientFactoryBean bean=new JAXRSClientFactoryBean(); bean.setAddress("http://localhost:" + PORT + "/test/services/rest3/bookstore/fastinfoset2"); bean.getInInterceptors().add(new FIStaxInInterceptor()); JAXBElementProvider p=new JAXBElementProvider(); p.setConsumeMediaTypes(Collections.singletonList("application/fastinfoset")); bean.setProvider(p); Map props=new HashMap(); props.put(FIStaxInInterceptor.FI_GET_SUPPORTED,Boolean.TRUE); bean.setProperties(props); WebClient client=bean.createWebClient(); Book b=client.accept("application/fastinfoset").get(Book.class); assertEquals("CXF2",b.getName()); assertEquals(2L,b.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookSubresourceParamExtensions() throws Exception { String baseAddress="http://localhost:" + PORT + "/test/services/rest"; BookStoreJaxrsJaxws proxy=JAXRSClientFactory.create(baseAddress,BookStoreJaxrsJaxws.class); WebClient.getConfig(proxy).getOutInterceptors().add(new LoggingOutInterceptor()); BookSubresource bs=proxy.getBookSubresource("139"); Book bean=new Book("CXF Rocks",139L); Book b=bs.getTheBook4(bean,bean,bean,bean); assertEquals(139,b.getId()); assertEquals("CXF Rocks",b.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookSubresourceClientNoProduces() throws Exception { String baseAddress="http://localhost:" + PORT + "/test/services/rest"; BookStoreJaxrsJaxws proxy=JAXRSClientFactory.create(baseAddress,BookStoreJaxrsJaxws.class); BookSubresource bs=proxy.getBookSubresource("125"); Book b=bs.getTheBookNoProduces(); assertEquals(125,b.getId()); assertEquals("CXF in Action",b.getName()); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetUnqualifiedBookSoap() throws Exception { String wsdlAddress="http://localhost:" + PORT + "/test/services/soap-transform/bookservice?wsdl"; BookSoapService service=new BookSoapService(new URL(wsdlAddress),new QName("http://books.com","BookService")); BookStoreJaxrsJaxws store=service.getBookPort(); TransformOutInterceptor out=new TransformOutInterceptor(); Map mapOut=new HashMap(); mapOut.put("{http://jaxws.jaxrs.systest.cxf.apache.org/}*","*"); out.setOutTransformElements(mapOut); TransformInInterceptor in=new TransformInInterceptor(); Map mapIn=new HashMap(); mapIn.put("getBookResponse","{http://jaxws.jaxrs.systest.cxf.apache.org/}getBookResponse"); in.setInTransformElements(mapIn); Client cl=ClientProxy.getClient(store); ((HTTPConduit)cl.getConduit()).getClient().setReceiveTimeout(10000000); cl.getInInterceptors().add(in); cl.getOutInterceptors().add(out); Book book=store.getBook(new Long(123)); assertEquals("id is wrong",book.getId(),123); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testPostBookTransformV2() throws Exception { String address="http://localhost:" + PORT + "/test/v2/rest-transform/bookstore/books"; WebClient client=WebClient.create(address); Book book=client.accept("text/xml").post(new Book(),Book.class); assertEquals(124L,book.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookSubresourceWebClientProxy2() throws Exception { WebClient client=WebClient.create("http://localhost:" + PORT + "/test/services/rest/bookstore").path("/books/378"); client.type(MediaType.TEXT_PLAIN_TYPE).accept(MediaType.APPLICATION_XML_TYPE); BookSubresource proxy=JAXRSClientFactory.fromClient(client,BookSubresource.class); Book b=proxy.getTheBook2("CXF ","in ","Acti","on ","- 3","7","8"); assertEquals(378,b.getId()); assertEquals("CXF in Action - 378",b.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBook123WebClient() throws Exception { String baseAddress="http://localhost:" + PORT + "/test/services/rest"; WebClient client=WebClient.create(baseAddress); client.path("/bookstore/123").accept(MediaType.APPLICATION_XML_TYPE); Book b=client.get(Book.class); assertEquals(123,b.getId()); assertEquals("CXF in Action",b.getName()); }

BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testServiceListingsAndWadl() throws Exception { String listings=getStringFromInputStream(getHttpInputStream("http://localhost:" + PORT + "/test/services")); assertNotNull(listings); assertTrue(listings.contains("http://localhost:" + PORT + "/test/services/soap/bookservice?wsdl")); assertFalse(listings.contains("http://localhost:" + PORT + "/test/services/soap/bookservice2?wsdl")); assertTrue(listings.contains("http://localhost:" + PORT + "/test/services/rest?_wadl")); assertEquals(200,WebClient.create("http://localhost:" + PORT + "/test/services/rest?_wadl&type=xml").get().getStatus()); assertTrue(listings.contains("http://localhost:" + PORT + "/test/services/rest2?_wadl")); assertEquals(200,WebClient.create("http://localhost:" + PORT + "/test/services/rest2?_wadl&type=xml").get().getStatus()); assertFalse(listings.contains("http://localhost:" + PORT + "/test/services/rest3?_wadl")); assertFalse(listings.contains("Atom Log Feed")); WebClient webClient=WebClient.create("http://localhost:" + PORT + "/test/services/rest3?_wadl"); assertEquals(404,webClient.get().getStatus()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testPostGetBookFastinfoset() throws Exception { JAXRSClientFactoryBean bean=new JAXRSClientFactoryBean(); bean.setAddress("http://localhost:" + PORT + "/test/services/rest3/bookstore/fastinfoset"); bean.getOutInterceptors().add(new FIStaxOutInterceptor()); bean.getInInterceptors().add(new FIStaxInInterceptor()); JAXBElementProvider p=new JAXBElementProvider(); p.setConsumeMediaTypes(Collections.singletonList("application/fastinfoset")); p.setProduceMediaTypes(Collections.singletonList("application/fastinfoset")); bean.setProvider(p); Map props=new HashMap(); props.put(FIStaxOutInterceptor.FI_ENABLED,Boolean.TRUE); bean.setProperties(props); WebClient client=bean.createWebClient(); Book b=new Book("CXF",1L); Book b2=client.type("application/fastinfoset").accept("application/fastinfoset").post(b,Book.class); assertEquals(b2.getName(),b.getName()); assertEquals(b2.getId(),b.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testCheckBookClientErrorResponse(){ String baseAddress="http://localhost:" + PORT + "/test/services/rest"; BookStoreJaxrsJaxws proxy=JAXRSClientFactory.create(baseAddress,BookStoreJaxrsJaxws.class,Collections.singletonList(new DummyResponseExceptionMapper())); Response response=proxy.checkBook(100L); assertEquals(HttpStatus.SC_NOT_FOUND,response.getStatus()); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testGetBook356ClientException() throws Exception { String baseAddress="http://localhost:" + PORT + "/test/services/rest"; BookStoreJaxrsJaxws proxy=JAXRSClientFactory.create(baseAddress,BookStoreJaxrsJaxws.class,Collections.singletonList(new TestResponseExceptionMapper())); try { proxy.getBook(356L); fail(); } catch ( BookNotFoundFault ex) { assertEquals("No Book with id 356 is available",ex.getMessage()); } }

Class: org.apache.cxf.systest.jaxrs.cdi.AbstractCDITest

EqualityVerifier 
@Test public void testResponseHasBeenReceivedWhenQueringAllBooks(){ Response r=createWebClient("/rest/api/bookstore/books").get(); assertEquals(Status.OK.getStatusCode(),r.getStatus()); }

InternalCallVerifier EqualityVerifier 
@Test public void testAddOneBookWithValidation(){ final String id=UUID.randomUUID().toString(); Response r=createWebClient("/rest/custom/bookstore/books").post(new Form().param("id",id)); assertEquals(Status.BAD_REQUEST.getStatusCode(),r.getStatus()); }

EqualityVerifier 
@Test public void testResponseHasBeenReceivedWhenAddingNewBook(){ Response r=createWebClient("/rest/api/bookstore/books").post(new Form().param("id","1234").param("name","Book 1234")); assertEquals(Status.CREATED.getStatusCode(),r.getStatus()); }

InternalCallVerifier EqualityVerifier 
@Test public void testInjectedVersionIsProperlyReturned(){ Response r=createWebClient("/rest/api/bookstore/version",MediaType.TEXT_PLAIN).get(); assertEquals(Status.OK.getStatusCode(),r.getStatus()); assertEquals("1.0",r.readEntity(String.class)); }

InternalCallVerifier EqualityVerifier 
@Test public void testAddAndQueryOneBook(){ final String id=UUID.randomUUID().toString(); Response r=createWebClient("/rest/api/bookstore/books").post(new Form().param("id",id).param("name","Book 1234")); assertEquals(Status.CREATED.getStatusCode(),r.getStatus()); r=createWebClient("/rest/api/bookstore/books").path(id).get(); assertEquals(Status.OK.getStatusCode(),r.getStatus()); Book book=r.readEntity(Book.class); assertEquals(id,book.getId()); }

Class: org.apache.cxf.systest.jaxrs.cors.CrossOriginSimpleTest

InternalCallVerifier EqualityVerifier 
@Test public void testAnnotatedLocalPreflightNoGo() throws Exception { configureAllowOrigins(true,null); String r=configClient.replacePath("/setAllowCredentials/false").accept("text/plain").post(null,String.class); assertEquals("ok",r); HttpClient httpclient=HttpClientBuilder.create().build(); HttpOptions http=new HttpOptions("http://localhost:" + PORT + "/antest/delete"); http.addHeader("Origin","http://area51.mil:4444"); http.addHeader(CorsHeaderConstants.HEADER_AC_REQUEST_METHOD,"DELETE"); HttpResponse response=httpclient.execute(http); assertEquals(200,response.getStatusLine().getStatusCode()); assertOriginResponse(false,new String[]{"http://area51.mil:4444"},false,response); if (httpclient instanceof Closeable) { ((Closeable)httpclient).close(); } }

InternalCallVerifier EqualityVerifier 
@Test public void testAnnotatedClassCorrectOrigin() throws Exception { HttpClient httpclient=HttpClientBuilder.create().build(); HttpGet httpget=new HttpGet("http://localhost:" + PORT + "/antest/simpleGet/HelloThere"); httpget.addHeader("Origin","http://area51.mil:31415"); HttpResponse response=httpclient.execute(httpget); assertEquals(200,response.getStatusLine().getStatusCode()); HttpEntity entity=response.getEntity(); String e=IOUtils.toString(entity.getContent(),"utf-8"); assertEquals("HelloThere",e); assertOriginResponse(false,new String[]{"http://area51.mil:31415"},true,response); if (httpclient instanceof Closeable) { ((Closeable)httpclient).close(); } }

InternalCallVerifier EqualityVerifier 
@Test public void testAnnotatedMethodPreflight() throws Exception { configureAllowOrigins(true,null); String r=configClient.replacePath("/setAllowCredentials/false").accept("text/plain").post(null,String.class); assertEquals("ok",r); HttpClient httpclient=HttpClientBuilder.create().build(); HttpOptions http=new HttpOptions("http://localhost:" + PORT + "/untest/annotatedPut"); http.addHeader("Origin","http://area51.mil:31415"); http.addHeader(CorsHeaderConstants.HEADER_AC_REQUEST_METHOD,"PUT"); http.addHeader(CorsHeaderConstants.HEADER_AC_REQUEST_HEADERS,"X-custom-1, x-custom-2"); HttpResponse response=httpclient.execute(http); assertEquals(200,response.getStatusLine().getStatusCode()); assertOriginResponse(false,new String[]{"http://area51.mil:31415"},true,response); assertAllowCredentials(response,true); List exposeHeadersValues=headerValues(response.getHeaders(CorsHeaderConstants.HEADER_AC_EXPOSE_HEADERS)); assertEquals(Collections.emptyList(),exposeHeadersValues); List allowHeadersValues=headerValues(response.getHeaders(CorsHeaderConstants.HEADER_AC_ALLOW_HEADERS)); assertEquals(Arrays.asList(new String[]{"X-custom-1","x-custom-2"}),allowHeadersValues); if (httpclient instanceof Closeable) { ((Closeable)httpclient).close(); } }

InternalCallVerifier EqualityVerifier 
@Test public void testAnnotatedSimple() throws Exception { configureAllowOrigins(true,null); String r=configClient.replacePath("/setAllowCredentials/false").accept("text/plain").post(null,String.class); assertEquals("ok",r); HttpClient httpclient=HttpClientBuilder.create().build(); HttpGet httpget=new HttpGet("http://localhost:" + PORT + "/untest/annotatedGet/HelloThere"); httpget.addHeader("Origin","http://area51.mil:31415"); HttpResponse response=httpclient.execute(httpget); assertEquals(200,response.getStatusLine().getStatusCode()); assertOriginResponse(false,new String[]{"http://area51.mil:31415"},true,response); assertAllowCredentials(response,false); List exposeHeadersValues=headerValues(response.getHeaders(CorsHeaderConstants.HEADER_AC_EXPOSE_HEADERS)); assertEquals(Arrays.asList(new String[]{"X-custom-3","X-custom-4"}),exposeHeadersValues); if (httpclient instanceof Closeable) { ((Closeable)httpclient).close(); } }

InternalCallVerifier EqualityVerifier 
@Test public void testAnnotatedMethodPreflight2() throws Exception { configureAllowOrigins(true,null); String r=configClient.replacePath("/setAllowCredentials/false").accept("text/plain").post(null,String.class); assertEquals("ok",r); HttpClient httpclient=HttpClientBuilder.create().build(); HttpOptions http=new HttpOptions("http://localhost:" + PORT + "/untest/annotatedPut2"); http.addHeader("Origin","http://area51.mil:31415"); http.addHeader(CorsHeaderConstants.HEADER_AC_REQUEST_METHOD,"PUT"); http.addHeader(CorsHeaderConstants.HEADER_AC_REQUEST_HEADERS,"X-custom-1, x-custom-2"); HttpResponse response=httpclient.execute(http); assertEquals(200,response.getStatusLine().getStatusCode()); assertOriginResponse(false,new String[]{"http://area51.mil:31415"},true,response); assertAllowCredentials(response,true); List exposeHeadersValues=headerValues(response.getHeaders(CorsHeaderConstants.HEADER_AC_EXPOSE_HEADERS)); assertEquals(Collections.emptyList(),exposeHeadersValues); List allowHeadersValues=headerValues(response.getHeaders(CorsHeaderConstants.HEADER_AC_ALLOW_HEADERS)); assertEquals(Arrays.asList(new String[]{"X-custom-1","x-custom-2"}),allowHeadersValues); if (httpclient instanceof Closeable) { ((Closeable)httpclient).close(); } }

InternalCallVerifier EqualityVerifier 
@Test public void preflightPostClassAnnotationPass() throws ClientProtocolException, IOException { HttpClient httpclient=HttpClientBuilder.create().build(); HttpOptions httpoptions=new HttpOptions("http://localhost:" + PORT + "/antest/unannotatedPost"); httpoptions.addHeader("Origin","http://area51.mil:31415"); httpoptions.addHeader("Content-Type","application/json"); httpoptions.addHeader(CorsHeaderConstants.HEADER_AC_REQUEST_METHOD,"POST"); httpoptions.addHeader(CorsHeaderConstants.HEADER_AC_REQUEST_HEADERS,"X-custom-1"); HttpResponse response=httpclient.execute(httpoptions); assertEquals(200,response.getStatusLine().getStatusCode()); Header[] origin=response.getHeaders(CorsHeaderConstants.HEADER_AC_ALLOW_ORIGIN); assertEquals(1,origin.length); assertEquals("http://area51.mil:31415",origin[0].getValue()); Header[] method=response.getHeaders(CorsHeaderConstants.HEADER_AC_ALLOW_METHODS); assertEquals(1,method.length); assertEquals("POST",method[0].getValue()); Header[] requestHeaders=response.getHeaders(CorsHeaderConstants.HEADER_AC_ALLOW_HEADERS); assertEquals(1,requestHeaders.length); assertEquals("X-custom-1",requestHeaders[0].getValue()); if (httpclient instanceof Closeable) { ((Closeable)httpclient).close(); } }

InternalCallVerifier EqualityVerifier 
@Test public void testAnnotatedLocalPreflight() throws Exception { configureAllowOrigins(true,null); String r=configClient.replacePath("/setAllowCredentials/false").accept("text/plain").post(null,String.class); assertEquals("ok",r); HttpClient httpclient=HttpClientBuilder.create().build(); HttpOptions http=new HttpOptions("http://localhost:" + PORT + "/antest/delete"); http.addHeader("Origin","http://area51.mil:3333"); http.addHeader(CorsHeaderConstants.HEADER_AC_REQUEST_METHOD,"DELETE"); HttpResponse response=httpclient.execute(http); assertEquals(200,response.getStatusLine().getStatusCode()); assertOriginResponse(false,new String[]{"http://area51.mil:3333"},true,response); assertAllowCredentials(response,false); List exposeHeadersValues=headerValues(response.getHeaders(CorsHeaderConstants.HEADER_AC_EXPOSE_HEADERS)); assertEquals(Collections.emptyList(),exposeHeadersValues); List allowedMethods=headerValues(response.getHeaders(CorsHeaderConstants.HEADER_AC_ALLOW_METHODS)); assertEquals(Arrays.asList("DELETE PUT"),allowedMethods); if (httpclient instanceof Closeable) { ((Closeable)httpclient).close(); } }

InternalCallVerifier EqualityVerifier 
@Test public void testNonSimpleActualRequest() throws Exception { configureAllowOrigins(true,null); String r=configClient.replacePath("/setAllowCredentials/false").accept("text/plain").post(null,String.class); assertEquals("ok",r); HttpClient httpclient=HttpClientBuilder.create().build(); HttpDelete httpdelete=new HttpDelete("http://localhost:" + PORT + "/untest/delete"); httpdelete.addHeader("Origin","http://localhost:" + PORT); HttpResponse response=httpclient.execute(httpdelete); assertEquals(200,response.getStatusLine().getStatusCode()); assertAllowCredentials(response,false); assertOriginResponse(true,null,true,response); if (httpclient instanceof Closeable) { ((Closeable)httpclient).close(); } }

InternalCallVerifier EqualityVerifier 
@Test public void testAllowCredentials() throws Exception { String r=configClient.replacePath("/setAllowCredentials/true").accept("text/plain").post(null,String.class); assertEquals("ok",r); HttpClient httpclient=HttpClientBuilder.create().build(); HttpGet httpget=new HttpGet("http://localhost:" + PORT + "/untest/simpleGet/HelloThere"); httpget.addHeader("Origin","http://localhost:" + PORT); HttpResponse response=httpclient.execute(httpget); assertEquals(200,response.getStatusLine().getStatusCode()); assertAllowCredentials(response,true); if (httpclient instanceof Closeable) { ((Closeable)httpclient).close(); } }

InternalCallVerifier EqualityVerifier 
@Test public void preflightPostClassAnnotationFail() throws ClientProtocolException, IOException { HttpClient httpclient=HttpClientBuilder.create().build(); HttpOptions httpoptions=new HttpOptions("http://localhost:" + PORT + "/antest/unannotatedPost"); httpoptions.addHeader("Origin","http://in.org"); httpoptions.addHeader("Content-Type","application/json"); httpoptions.addHeader(CorsHeaderConstants.HEADER_AC_REQUEST_METHOD,"POST"); httpoptions.addHeader(CorsHeaderConstants.HEADER_AC_REQUEST_HEADERS,"X-custom-1"); HttpResponse response=httpclient.execute(httpoptions); assertEquals(200,response.getStatusLine().getStatusCode()); assertEquals(0,response.getHeaders(CorsHeaderConstants.HEADER_AC_ALLOW_ORIGIN).length); assertEquals(0,response.getHeaders(CorsHeaderConstants.HEADER_AC_ALLOW_HEADERS).length); assertEquals(0,response.getHeaders(CorsHeaderConstants.HEADER_AC_ALLOW_METHODS).length); if (httpclient instanceof Closeable) { ((Closeable)httpclient).close(); } }

InternalCallVerifier EqualityVerifier 
@Test public void testForbidCredentials() throws Exception { String r=configClient.replacePath("/setAllowCredentials/false").accept("text/plain").post(null,String.class); assertEquals("ok",r); HttpClient httpclient=HttpClientBuilder.create().build(); HttpGet httpget=new HttpGet("http://localhost:" + PORT + "/untest/simpleGet/HelloThere"); httpget.addHeader("Origin","http://localhost:" + PORT); HttpResponse response=httpclient.execute(httpget); assertEquals(200,response.getStatusLine().getStatusCode()); assertAllowCredentials(response,false); if (httpclient instanceof Closeable) { ((Closeable)httpclient).close(); } }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void preflightPostClassAnnotationPass2() throws ClientProtocolException, IOException { HttpClient httpclient=HttpClientBuilder.create().build(); HttpOptions httpoptions=new HttpOptions("http://localhost:" + PORT + "/antest/unannotatedPost"); httpoptions.addHeader("Origin","http://area51.mil:31415"); httpoptions.addHeader("Content-Type","application/json"); httpoptions.addHeader(CorsHeaderConstants.HEADER_AC_REQUEST_METHOD,"POST"); httpoptions.addHeader(CorsHeaderConstants.HEADER_AC_REQUEST_HEADERS,"X-custom-1, X-custom-2"); HttpResponse response=httpclient.execute(httpoptions); assertEquals(200,response.getStatusLine().getStatusCode()); Header[] origin=response.getHeaders(CorsHeaderConstants.HEADER_AC_ALLOW_ORIGIN); assertEquals(1,origin.length); assertEquals("http://area51.mil:31415",origin[0].getValue()); Header[] method=response.getHeaders(CorsHeaderConstants.HEADER_AC_ALLOW_METHODS); assertEquals(1,method.length); assertEquals("POST",method[0].getValue()); Header[] requestHeaders=response.getHeaders(CorsHeaderConstants.HEADER_AC_ALLOW_HEADERS); assertEquals(1,requestHeaders.length); assertTrue(requestHeaders[0].getValue().contains("X-custom-1")); assertTrue(requestHeaders[0].getValue().contains("X-custom-2")); if (httpclient instanceof Closeable) { ((Closeable)httpclient).close(); } }

InternalCallVerifier EqualityVerifier 
@Test public void preflightPostClassAnnotationFail2() throws ClientProtocolException, IOException { HttpClient httpclient=HttpClientBuilder.create().build(); HttpOptions httpoptions=new HttpOptions("http://localhost:" + PORT + "/antest/unannotatedPost"); httpoptions.addHeader("Origin","http://area51.mil:31415"); httpoptions.addHeader("Content-Type","application/json"); httpoptions.addHeader(CorsHeaderConstants.HEADER_AC_REQUEST_METHOD,"POST"); httpoptions.addHeader(CorsHeaderConstants.HEADER_AC_REQUEST_HEADERS,"X-custom-3"); HttpResponse response=httpclient.execute(httpoptions); assertEquals(200,response.getStatusLine().getStatusCode()); assertEquals(0,response.getHeaders(CorsHeaderConstants.HEADER_AC_ALLOW_ORIGIN).length); assertEquals(0,response.getHeaders(CorsHeaderConstants.HEADER_AC_ALLOW_HEADERS).length); assertEquals(0,response.getHeaders(CorsHeaderConstants.HEADER_AC_ALLOW_METHODS).length); if (httpclient instanceof Closeable) { ((Closeable)httpclient).close(); } }

InternalCallVerifier EqualityVerifier 
@Test public void simplePostClassAnnotation() throws ClientProtocolException, IOException { HttpClient httpclient=HttpClientBuilder.create().build(); HttpOptions httpoptions=new HttpOptions("http://localhost:" + PORT + "/antest/unannotatedPost"); httpoptions.addHeader("Origin","http://in.org"); httpoptions.addHeader("Content-Type","text/plain"); httpoptions.addHeader(CorsHeaderConstants.HEADER_AC_REQUEST_METHOD,"POST"); HttpResponse response=httpclient.execute(httpoptions); assertEquals(200,response.getStatusLine().getStatusCode()); if (httpclient instanceof Closeable) { ((Closeable)httpclient).close(); } }

InternalCallVerifier EqualityVerifier 
@Test public void testAnnotatedClassWrongOrigin() throws Exception { HttpClient httpclient=HttpClientBuilder.create().build(); HttpGet httpget=new HttpGet("http://localhost:" + PORT + "/antest/simpleGet/HelloThere"); httpget.addHeader("Origin","http://su.us:1001"); HttpResponse response=httpclient.execute(httpget); assertEquals(200,response.getStatusLine().getStatusCode()); HttpEntity entity=response.getEntity(); String e=IOUtils.toString(entity.getContent(),"utf-8"); assertEquals("HelloThere",e); assertOriginResponse(false,null,false,response); if (httpclient instanceof Closeable) { ((Closeable)httpclient).close(); } }

Class: org.apache.cxf.systest.jaxrs.description.AbstractSwagger2ServiceDescriptionTest

InternalCallVerifier EqualityVerifier 
@Test public void testApiListingIsProperlyReturnedYAML() throws Exception { final WebClient client=createWebClient("/swagger.yaml"); try { final Response r=client.get(); assertEquals(Status.OK.getStatusCode(),r.getStatus()); Yaml yaml=new Yaml(); assertEquals(yaml.load(getExpectedValue(getExpectedFileYaml(),getPort())).toString(),yaml.load(IOUtils.readStringFromStream((InputStream)r.getEntity())).toString()); } finally { client.close(); } }

InternalCallVerifier EqualityVerifier 
@Test public void testApiListingIsProperlyReturnedJSON() throws Exception { final WebClient client=createWebClient("/swagger.json"); try { final Response r=client.get(); assertEquals(Status.OK.getStatusCode(),r.getStatus()); JSONAssert.assertEquals(getExpectedValue(getExpectedFileJson(),getPort()),IOUtils.readStringFromStream((InputStream)r.getEntity()),false); } finally { client.close(); } }

Class: org.apache.cxf.systest.jaxrs.description.AbstractSwaggerServiceDescriptionTest

EqualityVerifier 
@Test public void testNonRegisteredApiResourcesAreNotReturned() throws Exception { final Response r=createWebClient("/api-docs/books").get(); assertEquals(Status.NOT_FOUND.getStatusCode(),r.getStatus()); }

InternalCallVerifier EqualityVerifier 
@Test public void testApiListingIsProperlyReturned() throws Exception { final WebClient client=createWebClient("/api-docs"); try { final Response r=client.get(); assertEquals(Status.OK.getStatusCode(),r.getStatus()); JSONAssert.assertEquals(Json.createObjectBuilder().add("apiVersion","1.0.0").add("swaggerVersion","1.2").add("apis",Json.createArrayBuilder().add(Json.createObjectBuilder().add("path","/bookstore").add("description","Sample JAX-RS service with Swagger documentation"))).add("info",Json.createObjectBuilder().add("title","Sample REST Application").add("description","The Application").add("contact","users@cxf.apache.org").add("license","Apache 2.0 License").add("licenseUrl","http://www.apache.org/licenses/LICENSE-2.0.html")).build().toString(),IOUtils.readStringFromStream((InputStream)r.getEntity()),false); } finally { client.close(); } }

InternalCallVerifier EqualityVerifier 
@Test public void testApiResourcesAreProperlyReturned() throws Exception { final WebClient client=createWebClient("/api-docs/bookstore"); try { final Response r=client.get(); assertEquals(Status.OK.getStatusCode(),r.getStatus()); JSONAssert.assertEquals(Json.createObjectBuilder().add("apiVersion","1.0.0").add("swaggerVersion","1.2").add("basePath","http://localhost:" + getPort() + "/").add("resourcePath","/bookstore").add("apis",Json.createArrayBuilder().add(Json.createObjectBuilder().add("path","/bookstore/{id}").add("operations",Json.createArrayBuilder().add(DELETE_METHOD_SPEC).add(GET_BY_ID_METHOD_SPEC))).add(Json.createObjectBuilder().add("path","/bookstore").add("operations",Json.createArrayBuilder().add(GET_METHOD_SPEC)))).add("models",BOOK_MODEL_SPEC).build().toString(),IOUtils.readStringFromStream((InputStream)r.getEntity()),false); } finally { client.close(); } }

Class: org.apache.cxf.systest.jaxrs.discovery.JAXRSServerSpringDiscoveryTest

InternalCallVerifier EqualityVerifier 
@Test public void testThatClientDiscoversServiceProperly() throws Exception { BookStore bs=JAXRSClientFactory.create("http://localhost:" + PORT,BookStore.class,"org/apache/cxf/systest/jaxrs/discovery/jaxrs-http-client.xml"); assertEquals("http://localhost:" + PORT,WebClient.client(bs).getBaseURI().toString()); BookWithValidation book=bs.getBook("123"); assertEquals(book.getId(),"123"); }

EqualityVerifier 
@Test public void testParameterValidationFailsIfIdIsNull(){ final Response r=createWebClient("/bookstore/books").post(new Form().param("name","aa")); assertEquals(Status.BAD_REQUEST.getStatusCode(),r.getStatus()); }

EqualityVerifier 
@Test public void testResponseValidationFailsIfNameIsNull(){ final Response r=createWebClient("/bookstore/books").post(new Form().param("id","1")); assertEquals(Status.INTERNAL_SERVER_ERROR.getStatusCode(),r.getStatus()); }

Class: org.apache.cxf.systest.jaxrs.extraction.JAXRSClientServerTikaTest

EqualityVerifier 
@Test public void testUploadIndexAndSearchPdfFile(){ final WebClient wc=createWebClient("/catalog").type(MediaType.MULTIPART_FORM_DATA); final ContentDisposition disposition=new ContentDisposition("attachment;filename=testPDF.pdf"); final Attachment attachment=new Attachment("root",getClass().getResourceAsStream("/files/testPDF.pdf"),disposition); wc.post(new MultipartBody(attachment)); final Collection hits=search("modified=le=2007-09-16T09:00:00"); assertEquals(hits.size(),1); }

EqualityVerifier 
@Test public void testUploadIndexAndSearchPdfFileUsingUserDefinedDatePattern(){ final WebClient wc=createWebClient("/catalog").type(MediaType.MULTIPART_FORM_DATA); final ContentDisposition disposition=new ContentDisposition("attachment;filename=testPDF.pdf"); final Attachment attachment=new Attachment("root",getClass().getResourceAsStream("/files/testPDF.pdf"),disposition); wc.post(new MultipartBody(attachment)); final Collection hits=search("modified=le=2007/09/16"); assertEquals(hits.size(),1); }

Class: org.apache.cxf.systest.jaxrs.failover.AbstractFailoverTest

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testSequentialStrategyWithRetries() throws Exception { String address="http://localhost:" + NON_PORT + "/non-existent"; String address2="http://localhost:" + NON_PORT + "/non-existent2"; FailoverFeature feature=new FailoverFeature(); List alternateAddresses=new ArrayList(); alternateAddresses.add(address); alternateAddresses.add(address2); CustomRetryStrategy strategy=new CustomRetryStrategy(); strategy.setMaxNumberOfRetries(5); strategy.setAlternateAddresses(alternateAddresses); feature.setStrategy(strategy); BookStore store=getBookStore(address,feature); try { store.getBook("1"); fail("Exception expected"); } catch ( ProcessingException ex) { assertEquals(10,strategy.getTotalCount()); assertEquals(5,strategy.getAddressCount(address)); assertEquals(5,strategy.getAddressCount(address2)); } }

Class: org.apache.cxf.systest.jaxrs.failover.LoadDistributorTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testSingleAltAddress() throws Exception { LoadDistributorFeature feature=new LoadDistributorFeature(); List alternateAddresses=new ArrayList(); alternateAddresses.add(Server.ADDRESS2); SequentialStrategy strategy=new SequentialStrategy(); strategy.setAlternateAddresses(alternateAddresses); feature.setStrategy(strategy); BookStore bookStore=getBookStore(Server.ADDRESS1,feature); Book book=bookStore.getBook("123"); assertEquals("unexpected id",123L,book.getId()); book=bookStore.getBook("123"); assertEquals("unexpected id",123L,book.getId()); }

Class: org.apache.cxf.systest.jaxrs.jms.JAXRSJmsTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookFromWebClientWithPath() throws Exception { String endpointAddressUrlEncoded="jms:jndi:dynamicQueues/test.jmstransport.text" + "?jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory" + "&replyToName=dynamicQueues/test.jmstransport.response"+ "&jndiURL=tcp://localhost:" + JMS_PORT + "&jndiConnectionFactoryName=ConnectionFactory"; WebClient client=WebClient.create(endpointAddressUrlEncoded); client.path("bookstore").path("books").path("123"); Book book=client.get(Book.class); assertEquals("Get a wrong response code.",200,client.getResponse().getStatus()); assertEquals("Get a wrong book id.",123,book.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookFromProxyClientWithQuery() throws Exception { String endpointAddressUrlEncoded="jms:jndi:dynamicQueues/test.jmstransport.text" + "?jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory" + "&replyToName=dynamicQueues/test.jmstransport.response"+ "&jndiURL=tcp://localhost:" + JMS_PORT + "&jndiConnectionFactoryName=ConnectionFactory"; JMSBookStore client=JAXRSClientFactory.create(endpointAddressUrlEncoded,JMSBookStore.class); Book book=client.getBookByURLQuery(new String[]{"1","2","3"}); assertEquals("Get a wrong response code.",200,WebClient.client(client).getResponse().getStatus()); assertEquals("Get a wrong book id.",123,book.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookFromProxyClient() throws Exception { String endpointAddressUrlEncoded="jms:jndi:dynamicQueues/test.jmstransport.text" + "?jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory" + "&replyToName=dynamicQueues/test.jmstransport.response"+ "&jndiURL=tcp://localhost:" + JMS_PORT + "&jndiConnectionFactoryName=ConnectionFactory"; JMSBookStore client=JAXRSClientFactory.create(endpointAddressUrlEncoded,JMSBookStore.class); Book book=client.getBook("123"); assertEquals("Get a wrong response code.",200,WebClient.client(client).getResponse().getStatus()); assertEquals("Get a wrong book id.",123,book.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookFromSubresourceProxyClient() throws Exception { String endpointAddressUrlEncoded="jms:jndi:dynamicQueues/test.jmstransport.text" + "?jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory" + "&replyToName=dynamicQueues/test.jmstransport.response"+ "&jndiURL=tcp://localhost:" + JMS_PORT + "&jndiConnectionFactoryName=ConnectionFactory"; JMSBookStore client=JAXRSClientFactory.create(endpointAddressUrlEncoded,JMSBookStore.class); Book bookProxy=client.getBookSubResource("123"); Book book=bookProxy.retrieveState(); assertEquals("Get a wrong response code.",200,WebClient.client(bookProxy).getResponse().getStatus()); assertEquals("Get a wrong book id.",123,book.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookFromWebClient() throws Exception { String endpointAddressUrlEncoded="jms:jndi:dynamicQueues/test.jmstransport.text" + "?replyToName=dynamicQueues/test.jmstransport.response" + "&jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory"+ "&jndiURL=tcp://localhost:"+ JMS_PORT; WebClient client=WebClient.create(endpointAddressUrlEncoded); WebClient.getConfig(client).getRequestContext().put(org.apache.cxf.message.Message.REQUEST_URI,"/bookstore/books/123"); Book book=client.get(Book.class); assertEquals("Get a wrong response code.",200,client.getResponse().getStatus()); assertEquals("Get a wrong book id.",123,book.getId()); }

Class: org.apache.cxf.systest.jaxrs.provider.JsrJsonpProviderTest

TestInitializer EqualityVerifier HybridVerifier 
@Before public void setUp(){ final Response r=createWebClient("/bookstore/books").delete(); assertEquals(Status.OK.getStatusCode(),r.getStatus()); }

InternalCallVerifier EqualityVerifier ConditionMatcher HybridVerifier 
@Test public void testPostAndGetComplexJsonObject(){ testPostComplexJsonObject(); final Response r=createWebClient("/bookstore/books/1").get(); assertEquals(Status.OK.getStatusCode(),r.getStatus()); JsonObject obj=r.readEntity(JsonObject.class); assertThat(obj.getInt("id"),equalTo(1)); assertThat(obj.getString("name"),equalTo("Book 1")); assertThat(obj.get("chapters"),instanceOf(JsonArray.class)); final JsonArray chapters=(JsonArray)obj.get("chapters"); assertThat(chapters.size(),equalTo(2)); assertThat(((JsonObject)chapters.get(0)).getInt("id"),equalTo(1)); assertThat(((JsonObject)chapters.get(0)).getString("title"),equalTo("Chapter 1")); assertThat(((JsonObject)chapters.get(1)).getInt("id"),equalTo(2)); assertThat(((JsonObject)chapters.get(1)).getString("title"),equalTo("Chapter 2")); }

EqualityVerifier 
@Test public void testPostBadJsonObject(){ final Response r=createWebClient("/bookstore/books").header("Content-Type",MediaType.APPLICATION_JSON).post("blabla"); assertEquals(Status.BAD_REQUEST.getStatusCode(),r.getStatus()); }

EqualityVerifier 
@Test public void testPostComplexJsonObject(){ final Response r=createWebClient("/bookstore/books").header("Content-Type",MediaType.APPLICATION_JSON).post(Json.createObjectBuilder().add("id",1).add("name","Book 1").add("chapters",Json.createArrayBuilder().add(Json.createObjectBuilder().add("id",1).add("title","Chapter 1")).add(Json.createObjectBuilder().add("id",2).add("title","Chapter 2"))).build()); assertEquals(Status.CREATED.getStatusCode(),r.getStatus()); }

InternalCallVerifier EqualityVerifier ConditionMatcher HybridVerifier 
@Test public void testPostAndGetBooks(){ testPostSimpleJsonObject(); final Response r=createWebClient("/bookstore/books").get(); assertEquals(Status.OK.getStatusCode(),r.getStatus()); final JsonArray obj=r.readEntity(JsonArray.class); assertThat(obj.size(),equalTo(1)); assertThat(obj.get(0),instanceOf(JsonObject.class)); assertThat(((JsonObject)obj.get(0)).getInt("id"),equalTo(1)); assertThat(((JsonObject)obj.get(0)).getString("name"),equalTo("Book 1")); }

EqualityVerifier 
@Test public void testNoResultsAreReturned() throws Exception { final Response r=createWebClient("/bookstore/books/155").get(); assertEquals(Status.NO_CONTENT.getStatusCode(),r.getStatus()); }

EqualityVerifier 
@Test public void testPostSimpleJsonObject(){ final Response r=createWebClient("/bookstore/books").header("Content-Type",MediaType.APPLICATION_JSON).post(Json.createObjectBuilder().add("id",1).add("name","Book 1").build()); assertEquals(Status.CREATED.getStatusCode(),r.getStatus()); }

InternalCallVerifier EqualityVerifier ConditionMatcher HybridVerifier 
@Test public void testPostAndGetSimpleJsonObject(){ testPostSimpleJsonObject(); final Response r=createWebClient("/bookstore/books/1").get(); assertEquals(Status.OK.getStatusCode(),r.getStatus()); JsonObject obj=r.readEntity(JsonObject.class); assertThat(obj.getInt("id"),equalTo(1)); assertThat(obj.getString("name"),equalTo("Book 1")); assertThat(obj.get("chapters"),nullValue()); }

Class: org.apache.cxf.systest.jaxrs.security.JAXRS20HttpsBookTest

InternalCallVerifier EqualityVerifier 
@Test public void testGetBook() throws Exception { ClientBuilder builder=ClientBuilder.newBuilder(); KeyStore trustStore=loadStore("src/test/java/org/apache/cxf/systest/http/resources/Truststore.jks","password"); builder.trustStore(trustStore); builder.hostnameVerifier(new AllowAllHostnameVerifier()); KeyStore keyStore=loadStore("src/test/java/org/apache/cxf/systest/http/resources/Morpit.jks","password"); builder.keyStore(keyStore,"password"); Client client=builder.build(); client.register(new LoggingFeature()); WebTarget target=client.target("https://localhost:" + PORT + "/bookstore/securebooks/123"); Book b=target.request().accept(MediaType.APPLICATION_XML_TYPE).get(Book.class); assertEquals(123,b.getId()); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetBookSslContext() throws Exception { ClientBuilder builder=ClientBuilder.newBuilder(); SSLContext sslContext=createSSLContext(); builder.sslContext(sslContext); builder.hostnameVerifier(new AllowAllHostnameVerifier()); Client client=builder.build(); WebTarget target=client.target("https://localhost:" + PORT + "/bookstore/securebooks/123"); Book b=target.request().accept(MediaType.APPLICATION_XML_TYPE).get(Book.class); assertEquals(123,b.getId()); }

Class: org.apache.cxf.systest.jaxrs.security.JAXRSHttpsBookTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBook123ProxyToWebClient() throws Exception { BookStore bs=JAXRSClientFactory.create("https://localhost:" + PORT,BookStore.class,CLIENT_CONFIG_FILE1); Book b=bs.getSecureBook("123"); assertEquals(b.getId(),123); WebClient wc=WebClient.fromClient(WebClient.client(bs)); wc.path("/bookstore/securebooks/123").accept(MediaType.APPLICATION_XML_TYPE); Book b2=wc.get(Book.class); assertEquals(123,b2.getId()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetBook123WebClientFromSpringWildcard() throws Exception { ClassPathXmlApplicationContext ctx=new ClassPathXmlApplicationContext(new String[]{CLIENT_CONFIG_FILE5}); Object bean=ctx.getBean("bookService.proxyFactory"); assertNotNull(bean); JAXRSClientFactoryBean cfb=(JAXRSClientFactoryBean)bean; WebClient wc=(WebClient)cfb.create(); assertEquals("https://localhost:" + PORT,wc.getBaseURI().toString()); wc.accept("application/xml"); wc.path("bookstore/securebooks/123"); TheBook b=wc.get(TheBook.class); assertEquals(b.getId(),123); b=wc.get(TheBook.class); assertEquals(b.getId(),123); ctx.close(); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetBook123ProxyFromSpringWildcard() throws Exception { ClassPathXmlApplicationContext ctx=new ClassPathXmlApplicationContext(new String[]{CLIENT_CONFIG_FILE4}); Object bean=ctx.getBean("bookService.proxyFactory"); assertNotNull(bean); JAXRSClientFactoryBean cfb=(JAXRSClientFactoryBean)bean; BookStore bs=cfb.create(BookStore.class); assertEquals("https://localhost:" + PORT,WebClient.client(bs).getBaseURI().toString()); WebClient wc=WebClient.fromClient(WebClient.client(bs)); assertEquals("https://localhost:" + PORT,WebClient.client(bs).getBaseURI().toString()); wc.accept("application/xml"); wc.path("bookstore/securebooks/123"); TheBook b=wc.get(TheBook.class); assertEquals(b.getId(),123); b=wc.get(TheBook.class); assertEquals(b.getId(),123); ctx.close(); }

InternalCallVerifier EqualityVerifier NullVerifier IgnoredMethod HybridVerifier 
@Test @Ignore("Works in the studio only if local jaxrs.xsd is updated to have jaxrs:client") public void testGetBook123WebClientFromSpringWildcardOldJaxrsClient() throws Exception { ClassPathXmlApplicationContext ctx=new ClassPathXmlApplicationContext(new String[]{CLIENT_CONFIG_FILE_OLD}); Object bean=ctx.getBean("bookService.proxyFactory"); assertNotNull(bean); JAXRSClientFactoryBean cfb=(JAXRSClientFactoryBean)bean; WebClient wc=(WebClient)cfb.create(); assertEquals("https://localhost:" + PORT,wc.getBaseURI().toString()); wc.accept("application/xml"); wc.path("bookstore/securebooks/123"); TheBook b=wc.get(TheBook.class); assertEquals(b.getId(),123); b=wc.get(TheBook.class); assertEquals(b.getId(),123); ctx.close(); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBook123WebClientToProxy() throws Exception { WebClient wc=WebClient.create("https://localhost:" + PORT,CLIENT_CONFIG_FILE1); wc.path("/bookstore/securebooks/123").accept(MediaType.APPLICATION_XML_TYPE); Book b=wc.get(Book.class); assertEquals(123,b.getId()); wc.back(true); BookStore bs=JAXRSClientFactory.fromClient(wc,BookStore.class); Book b2=bs.getSecureBook("123"); assertEquals(b2.getId(),123); }

Class: org.apache.cxf.systest.jaxrs.security.JAXRSJaasConfigurationSecurityTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testJaasFilterAuthenticationFailure() throws Exception { String endpointAddress="http://localhost:" + PORT + "/service/jaasConfigFilter/bookstorestorage/thosebooks/123"; WebClient wc=WebClient.create(endpointAddress); wc.accept("text/xml"); wc.header(HttpHeaders.AUTHORIZATION,"Basic " + base64Encode("foo" + ":" + "bar1")); Response r=wc.get(); assertEquals(401,r.getStatus()); Object wwwAuthHeader=r.getMetadata().getFirst(HttpHeaders.WWW_AUTHENTICATE); assertNotNull(wwwAuthHeader); assertEquals("Basic",wwwAuthHeader.toString()); }

Class: org.apache.cxf.systest.jaxrs.security.JAXRSJaasSecurityTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testJaasFilterAuthenticationFailure() throws Exception { String endpointAddress="http://localhost:" + PORT + "/service/jaas2/bookstorestorage/thosebooks/123"; WebClient wc=WebClient.create(endpointAddress); AuthorizationPolicy pol=new AuthorizationPolicy(); pol.setUserName("foo"); pol.setPassword("bar1"); WebClient.getConfig(wc).getHttpConduit().setAuthorization(pol); wc.accept("application/xml"); Response r=wc.get(); assertEquals(401,r.getStatus()); Object wwwAuthHeader=r.getMetadata().getFirst(HttpHeaders.WWW_AUTHENTICATE); assertNotNull(wwwAuthHeader); assertEquals("Basic",wwwAuthHeader.toString()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testJaasFilterWebClientAuthorizationPolicy() throws Exception { String endpointAddress="http://localhost:" + PORT + "/service/jaas2/bookstorestorage/thosebooks/123"; WebClient wc=WebClient.create(endpointAddress); AuthorizationPolicy pol=new AuthorizationPolicy(); pol.setUserName("bob"); pol.setPassword("bobspassword"); WebClient.getConfig(wc).getHttpConduit().setAuthorization(pol); wc.accept("application/xml"); Book book=wc.get(Book.class); assertEquals(123L,book.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testJaasFilterProxyAuthorizationPolicy() throws Exception { String endpointAddress="http://localhost:" + PORT + "/service/jaas2"; SecureBookStoreNoAnnotations proxy=JAXRSClientFactory.create(endpointAddress,SecureBookStoreNoAnnotations.class,"bob","bobspassword",null); Book book=proxy.getThatBook(123L); assertEquals(123L,book.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testJaasFilterWebClientAuthorizationPolicy2() throws Exception { String endpointAddress="http://localhost:" + PORT + "/service/jaas2/bookstorestorage/thosebooks/123"; WebClient wc=WebClient.create(endpointAddress,"bob","bobspassword",null); wc.accept("application/xml"); Book book=wc.get(Book.class); assertEquals(123L,book.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testJaasFilterAuthenticationFailureWithRedirection() throws Exception { String endpointAddress="http://localhost:" + PORT + "/service/jaas2/bookstorestorage/thosebooks/123"; WebClient wc=WebClient.create(endpointAddress); wc.accept("text/xml,text/html"); wc.header(HttpHeaders.AUTHORIZATION,"Basic " + base64Encode("foo" + ":" + "bar1")); Response r=wc.get(); assertEquals(307,r.getStatus()); Object locationHeader=r.getMetadata().getFirst(HttpHeaders.LOCATION); assertNotNull(locationHeader); assertEquals("http://localhost:" + PORT + "/login.jsp",locationHeader.toString()); }

Class: org.apache.cxf.systest.jaxrs.security.JAXRSSpringSecurityClassTest

InternalCallVerifier EqualityVerifier 
@Test public void testBookFromForm() throws Exception { WebClient wc=WebClient.create("http://localhost:" + PORT + "/bookstorestorage/bookforms","foo","bar",null); wc.accept("application/xml"); Response r=wc.form(new Form().param("name","CXF Rocks").param("id","123")); Book b=readBook((InputStream)r.getEntity()); assertEquals("CXF Rocks",b.getName()); assertEquals(123L,b.getId()); }

InternalCallVerifier EqualityVerifier IgnoredMethod HybridVerifier 
@Test @Ignore("Spring Security 3 does not preserve POSTed form parameters as HTTPServletRequest parameters") public void testBookFromHttpRequestParameters() throws Exception { WebClient wc=WebClient.create("http://localhost:" + PORT + "/bookstorestorage/bookforms2","foo","bar",null); WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(100000000L); wc.accept("application/xml"); Response r=wc.form(new Form().param("name","CXF Rocks").param("id","123")); Book b=readBook((InputStream)r.getEntity()); assertEquals("CXF Rocks",b.getName()); assertEquals(123L,b.getId()); }

Class: org.apache.cxf.systest.jaxrs.security.jose.jwejws.JAXRSJweJwsTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testJweRsaJwsRsaCertInHeaders() throws Exception { String address="https://localhost:" + PORT + "/jwejwsrsaCertInHeaders"; BookStore bs=createJweJwsBookStore(address,null,null); WebClient.getConfig(bs).getRequestContext().put("rs.security.signature.include.cert","true"); WebClient.getConfig(bs).getRequestContext().put("rs.security.encryption.include.cert","true"); String text=bs.echoText("book"); assertEquals("book",text); }

InternalCallVerifier EqualityVerifier 
@Test public void testJwsJwkEC() throws Exception { String address="https://localhost:" + PORT + "/jwsjwkec"; JAXRSClientFactoryBean bean=new JAXRSClientFactoryBean(); SpringBusFactory bf=new SpringBusFactory(); URL busFile=JAXRSJweJwsTest.class.getResource("client.xml"); Bus springBus=bf.createBus(busFile.toString()); bean.setBus(springBus); bean.setServiceClass(BookStore.class); bean.setAddress(address); List providers=new LinkedList(); JwsWriterInterceptor jwsWriter=new JwsWriterInterceptor(); jwsWriter.setUseJwsOutputStream(true); providers.add(jwsWriter); providers.add(new JwsClientResponseFilter()); bean.setProviders(providers); bean.getProperties(true).put("rs.security.signature.out.properties","org/apache/cxf/systest/jaxrs/security/jws.ec.private.properties"); bean.getProperties(true).put("rs.security.signature.in.properties","org/apache/cxf/systest/jaxrs/security/jws.ec.public.properties"); BookStore bs=bean.create(BookStore.class); String text=bs.echoText("book"); assertEquals("book",text); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testJwsJwkPlainTextHMac() throws Exception { String address="https://localhost:" + PORT + "/jwsjwkhmac"; BookStore bs=createJwsBookStore(address,null); String text=bs.echoText("book"); assertEquals("book",text); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testJwsJwkBookHMac() throws Exception { String address="https://localhost:" + PORT + "/jwsjwkhmac"; BookStore bs=createJwsBookStore(address,Collections.singletonList(new JacksonJsonProvider())); Book book=bs.echoBook(new Book("book",123L)); assertEquals("book",book.getName()); assertEquals(123L,book.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testJweRsaJwsRsaXML() throws Exception { String address="https://localhost:" + PORT + "/jwejwsrsa"; BookStore bs=createJweJwsBookStore(address,null,null); Book book=new Book(); book.setName("book"); book=bs.echoBook2(book); assertEquals("book",book.getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testJweJwkBookBeanRSA() throws Exception { String address="https://localhost:" + PORT + "/jwejwkrsa"; BookStore bs=createJweBookStore(address,Collections.singletonList(new JacksonJsonProvider())); Book book=bs.echoBook(new Book("book",123L)); assertEquals("book",book.getName()); assertEquals(123L,book.getId()); }

InternalCallVerifier EqualityVerifier 
@Test public void testJweJwkAesWrap() throws Exception { String address="https://localhost:" + PORT + "/jwejwkaeswrap"; JAXRSClientFactoryBean bean=new JAXRSClientFactoryBean(); SpringBusFactory bf=new SpringBusFactory(); URL busFile=JAXRSJweJwsTest.class.getResource("client.xml"); Bus springBus=bf.createBus(busFile.toString()); bean.setBus(springBus); bean.setServiceClass(BookStore.class); bean.setAddress(address); List providers=new LinkedList(); JweWriterInterceptor jweWriter=new JweWriterInterceptor(); jweWriter.setUseJweOutputStream(true); providers.add(jweWriter); providers.add(new JweClientResponseFilter()); bean.setProviders(providers); bean.getProperties(true).put("rs.security.encryption.properties","org/apache/cxf/systest/jaxrs/security/secret.jwk.properties"); bean.getProperties(true).put("jose.debug",true); BookStore bs=bean.create(BookStore.class); String text=bs.echoText("book"); assertEquals("book",text); }

InternalCallVerifier EqualityVerifier 
@Test public void testJweAesCbcHmac() throws Exception { String address="https://localhost:" + PORT + "/jweaescbchmac"; JAXRSClientFactoryBean bean=new JAXRSClientFactoryBean(); SpringBusFactory bf=new SpringBusFactory(); URL busFile=JAXRSJweJwsTest.class.getResource("client.xml"); Bus springBus=bf.createBus(busFile.toString()); bean.setBus(springBus); bean.setServiceClass(BookStore.class); bean.setAddress(address); List providers=new LinkedList(); JweWriterInterceptor jweWriter=new JweWriterInterceptor(); jweWriter.setUseJweOutputStream(true); final String cekEncryptionKey="GawgguFyGrWKav7AX4VKUg"; AesWrapKeyEncryptionAlgorithm keyEncryption=new AesWrapKeyEncryptionAlgorithm(cekEncryptionKey,KeyAlgorithm.A128KW); jweWriter.setEncryptionProvider(new AesCbcHmacJweEncryption(ContentAlgorithm.A128CBC_HS256,keyEncryption)); JweClientResponseFilter jweReader=new JweClientResponseFilter(); jweReader.setDecryptionProvider(new AesCbcHmacJweDecryption(new AesWrapKeyDecryptionAlgorithm(cekEncryptionKey))); providers.add(jweWriter); providers.add(jweReader); bean.setProviders(providers); BookStore bs=bean.create(BookStore.class); String text=bs.echoText("book"); assertEquals("book",text); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testJweRsaJwsBookHMac() throws Exception { String address="https://localhost:" + PORT + "/jwejwshmac"; HmacJwsSignatureProvider hmacProvider=new HmacJwsSignatureProvider(ENCODED_MAC_KEY,SignatureAlgorithm.HS256); BookStore bs=createJweJwsBookStore(address,hmacProvider,Collections.singletonList(new JacksonJsonProvider())); Book book=bs.echoBook(new Book("book",123L)); assertEquals("book",book.getName()); assertEquals(123L,book.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testJweJwkPlainTextRSA() throws Exception { String address="https://localhost:" + PORT + "/jwejwkrsa"; BookStore bs=createJweBookStore(address,null); String text=bs.echoText("book"); assertEquals("book",text); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testJweRsaJwsPlainTextHMac() throws Exception { String address="https://localhost:" + PORT + "/jwejwshmac"; HmacJwsSignatureProvider hmacProvider=new HmacJwsSignatureProvider(ENCODED_MAC_KEY,SignatureAlgorithm.HS256); BookStore bs=createJweJwsBookStore(address,hmacProvider,null); String text=bs.echoText("book"); assertEquals("book",text); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testJweRsaJwsRsa() throws Exception { String address="https://localhost:" + PORT + "/jwejwsrsa"; BookStore bs=createJweJwsBookStore(address,null,null); String text=bs.echoText("book"); assertEquals("book",text); }

InternalCallVerifier EqualityVerifier 
@Test public void testJweRsaJwsRsaCert() throws Exception { String address="https://localhost:" + PORT + "/jwejwsrsacert"; JAXRSClientFactoryBean bean=new JAXRSClientFactoryBean(); SpringBusFactory bf=new SpringBusFactory(); URL busFile=JAXRSJweJwsTest.class.getResource("client.xml"); Bus springBus=bf.createBus(busFile.toString()); bean.setBus(springBus); bean.setServiceClass(BookStore.class); bean.setAddress(address); List providers=new LinkedList(); JweWriterInterceptor jweWriter=new JweWriterInterceptor(); jweWriter.setUseJweOutputStream(true); providers.add(jweWriter); providers.add(new JweClientResponseFilter()); JwsWriterInterceptor jwsWriter=new JwsWriterInterceptor(); jwsWriter.setUseJwsOutputStream(true); providers.add(jwsWriter); providers.add(new JwsClientResponseFilter()); bean.setProviders(providers); bean.getProperties(true).put("rs.security.keystore.file","org/apache/cxf/systest/jaxrs/security/certs/jwkPublicSet.txt"); bean.getProperties(true).put("rs.security.signature.out.properties",CLIENT_JWEJWS_PROPERTIES); bean.getProperties(true).put("rs.security.encryption.in.properties",CLIENT_JWEJWS_PROPERTIES); PrivateKeyPasswordProvider provider=new PrivateKeyPasswordProviderImpl(); bean.getProperties(true).put("rs.security.signature.key.password.provider",provider); bean.getProperties(true).put("rs.security.decryption.key.password.provider",provider); BookStore bs=bean.create(BookStore.class); WebClient.getConfig(bs).getRequestContext().put("rs.security.keystore.alias.jwe.out","AliceCert"); WebClient.getConfig(bs).getRequestContext().put("rs.security.keystore.alias.jws.in","AliceCert"); String text=bs.echoText("book"); assertEquals("book",text); }

Class: org.apache.cxf.systest.jaxrs.security.jose.jwejws.JAXRSJwsJsonTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testJweCompactJwsJsonBookBeanHmac() throws Exception { if (!SecurityTestUtil.checkUnrestrictedPoliciesInstalled()) { return; } String address="https://localhost:" + PORT + "/jwejwsjsonhmac"; List extraProviders=Arrays.asList(new JacksonJsonProvider(),new JweWriterInterceptor(),new JweClientResponseFilter()); String jwkStoreProperty="org/apache/cxf/systest/jaxrs/security/secret.jwk.properties"; Map props=new HashMap(); props.put("rs.security.signature.list.properties",jwkStoreProperty); props.put("rs.security.encryption.properties",jwkStoreProperty); BookStore bs=createBookStore(address,props,extraProviders); Book book=bs.echoBook(new Book("book",123L)); assertEquals("book",book.getName()); assertEquals(123L,book.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testJwsJsonBookBeanHmac() throws Exception { String address="https://localhost:" + PORT + "/jwsjsonhmac"; BookStore bs=createBookStore(address,"org/apache/cxf/systest/jaxrs/security/secret.jwk.properties",Collections.singletonList(new JacksonJsonProvider())); Book book=bs.echoBook(new Book("book",123L)); assertEquals("book",book.getName()); assertEquals(123L,book.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testJwsJsonPlainTextHmacXML() throws Exception { String address="https://localhost:" + PORT + "/jwsjsonhmac"; BookStore bs=createBookStore(address,"org/apache/cxf/systest/jaxrs/security/secret.jwk.properties",null); String text=bs.echoText("book"); assertEquals("book",text); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testJwsJsonBookDoubleHmacSinglePropsFile() throws Exception { String address="https://localhost:" + PORT + "/jwsjsonhmac2"; List properties=new ArrayList(); properties.add("org/apache/cxf/systest/jaxrs/security/secret.jwk.hmac2.properties"); BookStore bs=createBookStore(address,properties,null); Book book=bs.echoBook2(new Book("book",123L)); assertEquals("book",book.getName()); assertEquals(123L,book.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testJwsJsonPlainTextHmac() throws Exception { String address="https://localhost:" + PORT + "/jwsjsonhmac"; BookStore bs=createBookStore(address,"org/apache/cxf/systest/jaxrs/security/secret.jwk.properties",null); String text=bs.echoText("book"); assertEquals("book",text); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testJwsJsonBookDoubleHmac() throws Exception { String address="https://localhost:" + PORT + "/jwsjsonhmac2"; List properties=new ArrayList(); properties.add("org/apache/cxf/systest/jaxrs/security/secret.jwk.properties"); properties.add("org/apache/cxf/systest/jaxrs/security/secret.jwk.hmac.properties"); BookStore bs=createBookStore(address,properties,null); Book book=bs.echoBook(new Book("book",123L)); assertEquals("book",book.getName()); assertEquals(123L,book.getId()); }

Class: org.apache.cxf.systest.jaxrs.security.oauth.TemporaryCredentialServiceTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetTemporaryCredentialsURIQuery() throws Exception { Map parameters=new HashMap(); parameters.put(OAuth.OAUTH_CALLBACK,OAuthTestUtils.CALLBACK); for ( ParameterStyle style : ParameterStyle.values()) { for ( String signMethod : OAuthTestUtils.SIGN_METHOD) { LOG.log(Level.INFO,"Preparing request with parameter style: {0} and signature method: {1}",new String[]{style.toString(),signMethod}); parameters.put(OAuth.OAUTH_SIGNATURE_METHOD,signMethod); parameters.put(OAuth.OAUTH_NONCE,UUID.randomUUID().toString()); parameters.put(OAuth.OAUTH_TIMESTAMP,String.valueOf(System.currentTimeMillis() / 1000)); parameters.put(OAuth.OAUTH_CONSUMER_KEY,OAuthTestUtils.CLIENT_ID); OAuthMessage message=invokeRequestToken(parameters,style,OAuthServer.PORT); boolean isFormEncoded=OAuth.isFormEncoded(message.getBodyType()); Assert.assertTrue(isFormEncoded); List responseParams=OAuthTestUtils.getResponseParams(message); String wwwHeader=message.getHeader("Authenticate"); Assert.assertNull(wwwHeader); String callbacConf=OAuthTestUtils.findOAuthParameter(responseParams,OAuth.OAUTH_CALLBACK_CONFIRMED).getValue(); Assert.assertEquals("true",callbacConf); String oauthToken=OAuthTestUtils.findOAuthParameter(responseParams,OAuth.OAUTH_TOKEN).getKey(); Assert.assertFalse(StringUtils.isEmpty(oauthToken)); String tokenSecret=OAuthTestUtils.findOAuthParameter(responseParams,OAuth.OAUTH_TOKEN_SECRET).getKey(); Assert.assertFalse(StringUtils.isEmpty(tokenSecret)); parameters.put(OAuth.OAUTH_CONSUMER_KEY,"wrong"); message=invokeRequestToken(parameters,style,OAuthServer.PORT); String response=message.getHeader("oauth_problem"); Assert.assertEquals(OAuth.Problems.CONSUMER_KEY_UNKNOWN,response); } } }

Class: org.apache.cxf.systest.jaxrs.security.saml.JAXRSSamlAuthorizationTest

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testPostBookUserRole() throws Exception { String address="https://localhost:" + PORT + "/saml-roles/bookstore/books"; WebClient wc=createWebClient(address,null); wc.type(MediaType.APPLICATION_XML).accept(MediaType.APPLICATION_XML); try { wc.post(new Book("CXF",125L),Book.class); fail("403 is expected"); } catch ( WebApplicationException ex) { assertEquals(403,ex.getResponse().getStatus()); } }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testPostBookAdminWithWeakClaims() throws Exception { String address="https://localhost:" + PORT + "/saml-claims/bookstore/books"; Map props=new HashMap(); WebClient wc=createWebClient(address,props); wc.type(MediaType.APPLICATION_XML).accept(MediaType.APPLICATION_XML); try { wc.post(new Book("CXF",125L),Book.class); fail("403 is expected"); } catch ( WebApplicationException ex) { assertEquals(403,ex.getResponse().getStatus()); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testPostBookAdminRoleWithGoodSubjectName() throws Exception { String address="https://localhost:" + PORT + "/saml-roles2/bookstore/books"; Map props=new HashMap(); props.put("saml.roles",Collections.singletonList("admin")); props.put("saml.subject.name","bob@mycompany.com"); WebClient wc=createWebClient(address,props); wc.type(MediaType.APPLICATION_XML).accept(MediaType.APPLICATION_XML); Book book=wc.post(new Book("CXF",125L),Book.class); assertEquals(125L,book.getId()); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testPostBookAdminWithWeakClaims2() throws Exception { String address="https://localhost:" + PORT + "/saml-claims/bookstore/books"; Map props=new HashMap(); props.put("saml.roles",Collections.singletonList("admin")); props.put("saml.auth",Collections.singletonList("password")); WebClient wc=createWebClient(address,props); wc.type(MediaType.APPLICATION_XML).accept(MediaType.APPLICATION_XML); try { wc.post(new Book("CXF",125L),Book.class); fail("403 is expected"); } catch ( WebApplicationException ex) { assertEquals(403,ex.getResponse().getStatus()); } }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testPostBookAdminRoleWithWrongSubjectNameFormat() throws Exception { String address="https://localhost:" + PORT + "/saml-roles2/bookstore/books"; WebClient wc=createWebClient(address,Collections.singletonMap("saml.roles",Collections.singletonList("admin"))); wc.type(MediaType.APPLICATION_XML).accept(MediaType.APPLICATION_XML); try { wc.post(new Book("CXF",125L),Book.class); fail("403 is expected"); } catch ( WebApplicationException ex) { assertEquals(403,ex.getResponse().getStatus()); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testPostBookAdminRole() throws Exception { String address="https://localhost:" + PORT + "/saml-roles/bookstore/books"; WebClient wc=createWebClient(address,Collections.singletonMap("saml.roles",Collections.singletonList("admin"))); wc.type(MediaType.APPLICATION_XML).accept(MediaType.APPLICATION_XML); Book book=wc.post(new Book("CXF",125L),Book.class); assertEquals(125L,book.getId()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testPostBookAdminWithClaims() throws Exception { String address="https://localhost:" + PORT + "/saml-claims/bookstore/books"; Map props=new HashMap(); props.put("saml.roles",Collections.singletonList("admin")); props.put("saml.auth",Collections.singletonList("smartcard")); WebClient wc=createWebClient(address,props); wc.type(MediaType.APPLICATION_XML).accept(MediaType.APPLICATION_XML); Book book=wc.post(new Book("CXF",125L),Book.class); assertEquals(125L,book.getId()); }

Class: org.apache.cxf.systest.jaxrs.security.saml.JAXRSSamlTest

APIUtilityVerifier BranchVerifier UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testGetBookSAMLTokenInForm() throws Exception { String address="https://localhost:" + PORT + "/samlform/bookstore/books"; FormEncodingProvider formProvider=new FormEncodingProvider(); formProvider.setExpectedEncoded(true); WebClient wc=createWebClient(address,new SamlFormOutInterceptor(),formProvider); wc.type(MediaType.APPLICATION_FORM_URLENCODED).accept(MediaType.APPLICATION_XML); try { Book book=wc.post(new Form(new MetadataMap()).param("name","CXF").param("id","125"),Book.class); assertEquals(125L,book.getId()); } catch ( WebApplicationException ex) { fail(ex.getMessage()); } catch ( ProcessingException ex) { if (ex.getCause() != null && ex.getCause().getMessage() != null) { fail(ex.getCause().getMessage()); } else { fail(ex.getMessage()); } } }

APIUtilityVerifier BranchVerifier UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testGetBookPreviousSAMLTokenAsHeader() throws Exception { String address="https://localhost:" + PORT + "/samlheader/bookstore/books/123"; WebClient wc=createWebClientForExistingToken(address,new SamlHeaderOutInterceptor(),null); try { Book book=wc.get(Book.class); assertEquals(123L,book.getId()); } catch ( WebApplicationException ex) { fail(ex.getMessage()); } catch ( ProcessingException ex) { if (ex.getCause() != null && ex.getCause().getMessage() != null) { fail(ex.getCause().getMessage()); } else { fail(ex.getMessage()); } } }

InternalCallVerifier EqualityVerifier 
@Test public void testInvalidSAMLTokenAsHeader() throws Exception { String address="https://localhost:" + PORT + "/samlheader/bookstore/books/123"; JAXRSClientFactoryBean bean=new JAXRSClientFactoryBean(); bean.setAddress(address); SpringBusFactory bf=new SpringBusFactory(); URL busFile=JAXRSSamlTest.class.getResource("client.xml"); Bus springBus=bf.createBus(busFile.toString()); bean.setBus(springBus); WebClient wc=bean.createWebClient(); wc.header("Authorization","SAML invalid_grant"); Response r=wc.get(); assertEquals(401,r.getStatus()); }

APIUtilityVerifier BranchVerifier UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testGetBookSAMLTokenAsHeader() throws Exception { String address="https://localhost:" + PORT + "/samlheader/bookstore/books/123"; WebClient wc=createWebClient(address,new SamlHeaderOutInterceptor(),null); try { Book book=wc.get(Book.class); assertEquals(123L,book.getId()); } catch ( WebApplicationException ex) { fail(ex.getMessage()); } catch ( ProcessingException ex) { if (ex.getCause() != null && ex.getCause().getMessage() != null) { fail(ex.getCause().getMessage()); } else { fail(ex.getMessage()); } } }

APIUtilityVerifier BranchVerifier UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testGetBookPreviousSAMLTokenInForm() throws Exception { String address="https://localhost:" + PORT + "/samlform/bookstore/books"; FormEncodingProvider formProvider=new FormEncodingProvider(); formProvider.setExpectedEncoded(true); WebClient wc=createWebClientForExistingToken(address,new SamlFormOutInterceptor(),formProvider); wc.type(MediaType.APPLICATION_FORM_URLENCODED).accept(MediaType.APPLICATION_XML); try { Book book=wc.post(new Form(new MetadataMap()).param("name","CXF").param("id","125"),Book.class); assertEquals(125L,book.getId()); } catch ( WebApplicationException ex) { fail(ex.getMessage()); } catch ( ProcessingException ex) { if (ex.getCause() != null && ex.getCause().getMessage() != null) { fail(ex.getCause().getMessage()); } else { fail(ex.getMessage()); } } }

Class: org.apache.cxf.systest.jaxrs.security.xml.JAXRSXmlSecTest

EqualityVerifier 
@Test public void testPostEncryptedSignedBookInvalid() throws Exception { String address="https://localhost:" + test.port + "/xmlsec-validate/bookstore/books"; Map properties=new HashMap(); properties.put("security.callback-handler","org.apache.cxf.systest.jaxrs.security.saml.KeystorePasswordCallback"); properties.put("security.encryption.username","bob"); properties.put("security.encryption.properties","org/apache/cxf/systest/jaxrs/security/bob.properties"); properties.put("security.signature.username","alice"); properties.put("security.signature.properties","org/apache/cxf/systest/jaxrs/security/alice.properties"); EncryptionProperties encryptionProperties=new EncryptionProperties(); encryptionProperties.setEncryptionSymmetricKeyAlgo("http://www.w3.org/2009/xmlenc11#aes128-gcm"); encryptionProperties.setEncryptionKeyIdType(RSSecurityUtils.X509_CERT); try { doTestPostEncryptedBook(address,true,properties,encryptionProperties,true,test.streaming); } catch ( BadRequestException ex) { assertEquals(400,ex.getResponse().getStatus()); } }

InternalCallVerifier EqualityVerifier 
@Test public void testOldConfiguration() throws Exception { String address="https://localhost:" + test.port + "/xmlsig"; JAXRSClientFactoryBean bean=new JAXRSClientFactoryBean(); bean.setAddress(address); SpringBusFactory bf=new SpringBusFactory(); URL busFile=JAXRSXmlSecTest.class.getResource("client.xml"); Bus springBus=bf.createBus(busFile.toString()); bean.setBus(springBus); Map newProperties=new HashMap<>(); newProperties.put("ws-security.callback-handler","org.apache.cxf.systest.jaxrs.security.saml.KeystorePasswordCallback"); newProperties.put("ws-security.signature.username","alice"); String cryptoUrl="org/apache/cxf/systest/jaxrs/security/alice.properties"; newProperties.put("ws-security.signature.properties",cryptoUrl); bean.setProperties(newProperties); if (test.streaming) { XmlSecOutInterceptor sigInterceptor=new XmlSecOutInterceptor(); sigInterceptor.setSignRequest(true); bean.getOutInterceptors().add(sigInterceptor); } else { XmlSigOutInterceptor sigInterceptor=new XmlSigOutInterceptor(); bean.getOutInterceptors().add(sigInterceptor); } bean.setServiceClass(BookStore.class); BookStore store=bean.create(BookStore.class); Book book=store.addBook(new Book("CXF",126L)); assertEquals(126L,book.getId()); }

Class: org.apache.cxf.systest.jaxrs.tracing.htrace.HTraceTracingCustomHeadersTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier ConditionMatcher HybridVerifier 
@Test public void testThatNewChildSpanIsCreated(){ final Response r=createWebClient("/bookstore/books",htraceClientProvider).get(); assertEquals(Status.OK.getStatusCode(),r.getStatus()); assertThat((String)r.getHeaders().getFirst(CUSTOM_HEADER_SPAN_ID),notNullValue()); }

InternalCallVerifier EqualityVerifier ConditionMatcher HybridVerifier 
@Test public void testThatNewSpanIsCreated(){ final SpanId spanId=SpanId.fromRandom(); final Response r=createWebClient("/bookstore/books").header(CUSTOM_HEADER_SPAN_ID,spanId.toString()).get(); assertEquals(Status.OK.getStatusCode(),r.getStatus()); assertThat((String)r.getHeaders().getFirst(CUSTOM_HEADER_SPAN_ID),equalTo(spanId.toString())); }

Class: org.apache.cxf.systest.jaxrs.tracing.htrace.HTraceTracingTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier ConditionMatcher HybridVerifier 
@Test public void testThatNewChildSpanIsCreatedWhenParentIsProvided(){ final Response r=createWebClient("/bookstore/books",htraceClientProvider).get(); assertEquals(Status.OK.getStatusCode(),r.getStatus()); assertThat(TestSpanReceiver.getAllSpans().size(),equalTo(3)); assertThat(TestSpanReceiver.getAllSpans().get(0).getDescription(),equalTo("Get Books")); assertThat(TestSpanReceiver.getAllSpans().get(0).getParents().length,equalTo(1)); assertTrue(r.getHeaders().containsKey(TracerHeaders.DEFAULT_HEADER_SPAN_ID)); }

InternalCallVerifier EqualityVerifier ConditionMatcher HybridVerifier 
@Test public void testThatCurrentSpanIsAnnotatedWithKeyValue(){ final SpanId spanId=SpanId.fromRandom(); final Response r=createWebClient("/bookstore/book/1").header(TracerHeaders.DEFAULT_HEADER_SPAN_ID,spanId.toString()).get(); assertEquals(Status.OK.getStatusCode(),r.getStatus()); assertThat(TestSpanReceiver.getAllSpans().size(),equalTo(1)); assertThat(TestSpanReceiver.getAllSpans().get(0).getDescription(),equalTo("GET bookstore/book/1")); assertThat(TestSpanReceiver.getAllSpans().get(0).getKVAnnotations().size(),equalTo(1)); assertThat((String)r.getHeaders().getFirst(TracerHeaders.DEFAULT_HEADER_SPAN_ID),equalTo(spanId.toString())); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier ConditionMatcher HybridVerifier 
@Test public void testThatNewSpanIsCreatedWhenNotProvidedUsingAsyncClient() throws Exception { final WebClient client=createWebClient("/bookstore/books",htraceClientProvider); final Future f=client.async().get(); final Response r=f.get(1,TimeUnit.SECONDS); assertEquals(Status.OK.getStatusCode(),r.getStatus()); assertThat(TestSpanReceiver.getAllSpans().size(),equalTo(3)); assertThat(TestSpanReceiver.getAllSpans().get(0).getDescription(),equalTo("Get Books")); assertThat(TestSpanReceiver.getAllSpans().get(1).getDescription(),equalTo("GET bookstore/books")); assertThat(TestSpanReceiver.getAllSpans().get(2).getDescription(),equalTo("GET " + client.getCurrentURI())); assertTrue(r.getHeaders().containsKey(TracerHeaders.DEFAULT_HEADER_SPAN_ID)); }

BooleanVerifier InternalCallVerifier EqualityVerifier ConditionMatcher HybridVerifier 
@Test public void testThatNewSpanIsCreatedWhenNotProvided(){ final Response r=createWebClient("/bookstore/books").get(); assertEquals(Status.OK.getStatusCode(),r.getStatus()); assertThat(TestSpanReceiver.getAllSpans().size(),equalTo(2)); assertThat(TestSpanReceiver.getAllSpans().get(0).getDescription(),equalTo("Get Books")); assertThat(TestSpanReceiver.getAllSpans().get(1).getDescription(),equalTo("GET bookstore/books")); assertFalse(r.getHeaders().containsKey(TracerHeaders.DEFAULT_HEADER_SPAN_ID)); }

EqualityVerifier ConditionMatcher HybridVerifier 
@Test public void testThatNewSpanIsCreatedUsingAsyncInvocation(){ final Response r=createWebClient("/bookstore/books/async").get(); assertEquals(Status.OK.getStatusCode(),r.getStatus()); assertThat(TestSpanReceiver.getAllSpans().size(),equalTo(2)); assertThat(TestSpanReceiver.getAllSpans().get(1).getDescription(),equalTo("GET bookstore/books/async")); assertThat(TestSpanReceiver.getAllSpans().get(0).getDescription(),equalTo("Processing books")); }

InternalCallVerifier EqualityVerifier ConditionMatcher HybridVerifier 
@Test public void testThatParallelSpanIsAnnotatedWithTimeline(){ final SpanId spanId=SpanId.fromRandom(); final Response r=createWebClient("/bookstore/process").header(TracerHeaders.DEFAULT_HEADER_SPAN_ID,spanId.toString()).put(""); assertEquals(Status.OK.getStatusCode(),r.getStatus()); assertThat(TestSpanReceiver.getAllSpans().size(),equalTo(2)); assertThat(TestSpanReceiver.getAllSpans().get(0).getDescription(),equalTo("PUT bookstore/process")); assertThat(TestSpanReceiver.getAllSpans().get(0).getTimelineAnnotations().size(),equalTo(0)); assertThat(TestSpanReceiver.getAllSpans().get(1).getDescription(),equalTo("Processing books")); assertThat(TestSpanReceiver.getAllSpans().get(1).getTimelineAnnotations().size(),equalTo(1)); assertThat((String)r.getHeaders().getFirst(TracerHeaders.DEFAULT_HEADER_SPAN_ID),equalTo(spanId.toString())); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier ConditionMatcher HybridVerifier 
@Test public void testThatProvidedSpanIsNotClosedWhenActive() throws MalformedURLException { try (final TraceScope scope=tracer.newScope("test span")){ final Response r=createWebClient("/bookstore/books",htraceClientProvider).get(); assertEquals(Status.OK.getStatusCode(),r.getStatus()); assertThat(TestSpanReceiver.getAllSpans().size(),equalTo(2)); assertThat(TestSpanReceiver.getAllSpans().get(0).getDescription(),equalTo("Get Books")); assertThat(TestSpanReceiver.getAllSpans().get(0).getParents().length,equalTo(1)); assertThat(TestSpanReceiver.getAllSpans().get(1).getDescription(),equalTo("GET bookstore/books")); assertTrue(r.getHeaders().containsKey(TracerHeaders.DEFAULT_HEADER_SPAN_ID)); } assertThat(TestSpanReceiver.getAllSpans().size(),equalTo(3)); assertThat(TestSpanReceiver.getAllSpans().get(2).getDescription(),equalTo("test span")); }

InternalCallVerifier EqualityVerifier ConditionMatcher HybridVerifier 
@Test public void testThatNewInnerSpanIsCreated(){ final SpanId spanId=SpanId.fromRandom(); final Response r=createWebClient("/bookstore/books").header(TracerHeaders.DEFAULT_HEADER_SPAN_ID,spanId.toString()).get(); assertEquals(Status.OK.getStatusCode(),r.getStatus()); assertThat(TestSpanReceiver.getAllSpans().size(),equalTo(2)); assertThat(TestSpanReceiver.getAllSpans().get(0).getDescription(),equalTo("Get Books")); assertThat(TestSpanReceiver.getAllSpans().get(1).getDescription(),equalTo("GET bookstore/books")); assertThat((String)r.getHeaders().getFirst(TracerHeaders.DEFAULT_HEADER_SPAN_ID),equalTo(spanId.toString())); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier ConditionMatcher HybridVerifier 
@Test public void testThatProvidedSpanIsNotDetachedWhenActiveUsingAsyncClient() throws Exception { final WebClient client=createWebClient("/bookstore/books",htraceClientProvider); try (final TraceScope scope=tracer.newScope("test span")){ final Future f=client.async().get(); final Response r=f.get(1,TimeUnit.SECONDS); assertEquals(Status.OK.getStatusCode(),r.getStatus()); assertThat(Tracer.getCurrentSpan(),equalTo(scope.getSpan())); assertThat(TestSpanReceiver.getAllSpans().size(),equalTo(2)); assertThat(TestSpanReceiver.getAllSpans().get(0).getDescription(),equalTo("Get Books")); assertThat(TestSpanReceiver.getAllSpans().get(1).getDescription(),equalTo("GET bookstore/books")); assertTrue(r.getHeaders().containsKey(TracerHeaders.DEFAULT_HEADER_SPAN_ID)); } assertThat(TestSpanReceiver.getAllSpans().get(2).getDescription(),equalTo("test span")); }

InternalCallVerifier EqualityVerifier ConditionMatcher HybridVerifier 
@Test public void testThatNewInnerSpanIsCreatedUsingAsyncInvocation(){ final SpanId spanId=SpanId.fromRandom(); final Response r=createWebClient("/bookstore/books/async").header(TracerHeaders.DEFAULT_HEADER_SPAN_ID,spanId.toString()).get(); assertEquals(Status.OK.getStatusCode(),r.getStatus()); assertThat(TestSpanReceiver.getAllSpans().size(),equalTo(2)); assertThat(TestSpanReceiver.getAllSpans().get(1).getDescription(),equalTo("GET bookstore/books/async")); assertThat(TestSpanReceiver.getAllSpans().get(0).getDescription(),equalTo("Processing books")); assertThat((String)r.getHeaders().getFirst(TracerHeaders.DEFAULT_HEADER_SPAN_ID),equalTo(spanId.toString())); }

InternalCallVerifier EqualityVerifier ConditionMatcher HybridVerifier 
@Test public void testThatOuterSpanIsCreatedUsingAsyncInvocation(){ final SpanId spanId=SpanId.fromRandom(); final Response r=createWebClient("/bookstore/books/async/notrace").header(TracerHeaders.DEFAULT_HEADER_SPAN_ID,spanId.toString()).get(); assertEquals(Status.OK.getStatusCode(),r.getStatus()); assertThat(TestSpanReceiver.getAllSpans().size(),equalTo(1)); assertThat(TestSpanReceiver.getAllSpans().get(0).getDescription(),equalTo("GET bookstore/books/async/notrace")); assertThat((String)r.getHeaders().getFirst(TracerHeaders.DEFAULT_HEADER_SPAN_ID),equalTo(spanId.toString())); }

InternalCallVerifier EqualityVerifier ConditionMatcher HybridVerifier 
@Test public void testThatInnerSpanIsCreatedUsingPseudoAsyncInvocation(){ final SpanId spanId=SpanId.fromRandom(); final Response r=createWebClient("/bookstore/books/pseudo-async").header(TracerHeaders.DEFAULT_HEADER_SPAN_ID,spanId.toString()).get(); assertEquals(Status.OK.getStatusCode(),r.getStatus()); assertThat(TestSpanReceiver.getAllSpans().size(),equalTo(2)); assertThat(TestSpanReceiver.getAllSpans().get(1).getDescription(),equalTo("GET bookstore/books/pseudo-async")); assertThat(TestSpanReceiver.getAllSpans().get(0).getDescription(),equalTo("Processing books")); assertThat((String)r.getHeaders().getFirst(TracerHeaders.DEFAULT_HEADER_SPAN_ID),equalTo(spanId.toString())); }

Class: org.apache.cxf.systest.jaxrs.validation.JAXRSClientServerValidationTest

EqualityVerifier 
@Test public void testThatPatternValidationFails() throws Exception { final Response r=createWebClient("/bookstore/books/blabla").get(); assertEquals(Status.BAD_REQUEST.getStatusCode(),r.getStatus()); }

EqualityVerifier 
@Test public void testThatNoValidationConstraintsAreViolatedWithBook(){ final Response r=createWebClient("/bookstore/books/direct").type("text/xml").post(new BookWithValidation("BeanVal","1")); assertEquals(Status.CREATED.getStatusCode(),r.getStatus()); }

EqualityVerifier 
@Test public void testThatValidationConstraintsAreViolatedWithBook(){ final Response r=createWebClient("/bookstore/books/direct").type("text/xml").post(new BookWithValidation("BeanVal")); assertEquals(Status.BAD_REQUEST.getStatusCode(),r.getStatus()); }

EqualityVerifier 
@Test public void testThatResponseValidationForOneBookSubNotFails(){ Response r=createWebClient("/bookstore/books").post(new Form().param("id","1234").param("name","cxf")); assertEquals(Status.CREATED.getStatusCode(),r.getStatus()); r=createWebClient("/bookstore/sub/books/1234").get(); assertEquals(200,r.getStatus()); }

EqualityVerifier 
@Test public void testThatResponseValidationForNullBookFails(){ Response r=createWebClient("/bookstore/books").post(new Form().param("id","1234").param("name","cxf")); assertEquals(Status.CREATED.getStatusCode(),r.getStatus()); r=createWebClient("/bookstore/books/1235").get(); assertEquals(500,r.getStatus()); }

EqualityVerifier 
@Test public void testThatNoValidationConstraintsAreViolated(){ final Response r=createWebClient("/bookstore/books").query("page","2").get(); assertEquals(Status.OK.getStatusCode(),r.getStatus()); }

EqualityVerifier 
@Test public void testThatNoValidationConstraintsAreViolatedWithDefaultValue(){ final Response r=createWebClient("/bookstore/books").get(); assertEquals(Status.OK.getStatusCode(),r.getStatus()); }

EqualityVerifier 
@Test public void testThatResponseValidationForOneBookFails(){ Response r=createWebClient("/bookstore/books").post(new Form().param("id","1234")); assertEquals(Status.CREATED.getStatusCode(),r.getStatus()); r=createWebClient("/bookstore/books/1234").get(); assertEquals(Status.INTERNAL_SERVER_ERROR.getStatusCode(),r.getStatus()); }

EqualityVerifier 
@Test public void testThatMinValidationFails(){ final Response r=createWebClient("/bookstore/books").query("page","0").get(); assertEquals(Status.BAD_REQUEST.getStatusCode(),r.getStatus()); }

EqualityVerifier 
@Test public void testThatResponseValidationIsNotTriggeredForUnacceptableMediaType(){ final Response r=createWebClient("/bookstore/books/direct").type(MediaType.APPLICATION_JSON).post(new BookWithValidation("BeanVal","1")); assertEquals(Status.UNSUPPORTED_MEDIA_TYPE.getStatusCode(),r.getStatus()); }

EqualityVerifier 
@Test public void testThatResponseValidationForBookPassesWhenNoConstraintsAreDefined(){ Response r=createWebClient("/bookstore/booksResponseNoValidation/1234").get(); assertEquals(Status.OK.getStatusCode(),r.getStatus()); r=createWebClient("/bookstore/books").post(new Form().param("id","1234")); assertEquals(Status.CREATED.getStatusCode(),r.getStatus()); r=createWebClient("/bookstore/booksResponseNoValidation/1234").get(); assertEquals(Status.OK.getStatusCode(),r.getStatus()); }

EqualityVerifier 
@Test public void testThatValidationConstraintsAreViolatedWithBooks(){ final Response r=createWebClient("/bookstore/books/directmany").type("text/xml").postCollection(Collections.singletonList(new BookWithValidation("BeanVal")),BookWithValidation.class); assertEquals(Status.BAD_REQUEST.getStatusCode(),r.getStatus()); }

EqualityVerifier 
@Test public void testThatSizeValidationFails(){ final Response r=createWebClient("/bookstore/books").post(new Form().param("id","")); assertEquals(Status.BAD_REQUEST.getStatusCode(),r.getStatus()); }

TestInitializer EqualityVerifier HybridVerifier 
@Before public void setUp(){ final Response r=createWebClient("/bookstore/books").delete(); assertEquals(Status.OK.getStatusCode(),r.getStatus()); }

EqualityVerifier 
@Test public void testThatNotNullValidationFails(){ final Response r=createWebClient("/bookstore/books").post(new Form()); assertEquals(Status.BAD_REQUEST.getStatusCode(),r.getStatus()); }

EqualityVerifier 
@Test public void testThatResponseValidationForOneBookNotFails(){ Response r=createWebClient("/bookstore/books").post(new Form().param("id","1234").param("name","cxf")); assertEquals(Status.CREATED.getStatusCode(),r.getStatus()); r=createWebClient("/bookstore/books/1234").get(); assertEquals(200,r.getStatus()); }

EqualityVerifier 
@Test public void testThatResponseValidationForAllBooksFails(){ Response r=createWebClient("/bookstore/books").post(new Form().param("id","1234")); assertEquals(Status.CREATED.getStatusCode(),r.getStatus()); r=createWebClient("/bookstore/books").get(); assertEquals(Status.INTERNAL_SERVER_ERROR.getStatusCode(),r.getStatus()); }

EqualityVerifier 
@Test public void testThatResponseValidationForOneResponseBookFails(){ Response r=createWebClient("/bookstore/booksResponse/1234").get(); assertEquals(Status.INTERNAL_SERVER_ERROR.getStatusCode(),r.getStatus()); r=createWebClient("/bookstore/books").post(new Form().param("id","1234")); assertEquals(Status.CREATED.getStatusCode(),r.getStatus()); r=createWebClient("/bookstore/booksResponse/1234").get(); assertEquals(Status.INTERNAL_SERVER_ERROR.getStatusCode(),r.getStatus()); }

Class: org.apache.cxf.systest.jaxrs.validation.JAXRSPerRequestValidationTest

EqualityVerifier 
@Test public void testThatValidationConstraintsAreViolatedWhenBookDoesNotExistResponse(){ final Response r=createWebClient("/bookstore/bookResponse").query("id","3333").get(); assertEquals(Status.INTERNAL_SERVER_ERROR.getStatusCode(),r.getStatus()); }

EqualityVerifier 
@Test public void testThatValidationConstraintsAreViolatedWhenBookNameIsNotSet(){ final Response r=createWebClient("/bookstore/book").query("id","124").get(); assertEquals(Status.INTERNAL_SERVER_ERROR.getStatusCode(),r.getStatus()); }

EqualityVerifier 
@Test public void testThatNoValidationConstraintsAreViolatedWhenBookIdIsSet(){ final Response r=createWebClient("/bookstore/book").query("id","123").get(); assertEquals(Status.OK.getStatusCode(),r.getStatus()); }

EqualityVerifier 
@Test public void testThatValidationConstraintsAreViolatedWhenBookDoesNotExist(){ final Response r=createWebClient("/bookstore/book").query("id","3333").get(); assertEquals(Status.INTERNAL_SERVER_ERROR.getStatusCode(),r.getStatus()); }

EqualityVerifier 
@Test public void testThatValidationConstraintsAreViolatedWhenBookIdIsNotSet(){ final Response r=createWebClient("/bookstore/book").get(); assertEquals(Status.BAD_REQUEST.getStatusCode(),r.getStatus()); }

Class: org.apache.cxf.systest.jaxrs.validation.spring.JAXRSClientServerValidationSpringTest

APIUtilityVerifier UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testHelloRestValidationFailsIfNameIsNull() throws Exception { String address="http://localhost:" + PORT + "/bwrest"; BookWorld service=JAXRSClientFactory.create(address,BookWorld.class); BookWithValidation bw=service.echoBook(new BookWithValidation("RS","123")); assertEquals("123",bw.getId()); try { service.echoBook(new BookWithValidation(null,"123")); fail("Validation failure expected"); } catch ( BadRequestException ex) { } }

EqualityVerifier 
@Test public void testProgrammaticValidationFailsIfNameIsNull(){ final Response r=createWebClient("/jaxrs/bookstore/books").post(new Form().param("id","1")); assertEquals(Status.BAD_REQUEST.getStatusCode(),r.getStatus()); }

APIUtilityVerifier UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testHelloSoapValidationFailsIfNameIsNull() throws Exception { final QName serviceName=new QName("http://bookworld.com","BookWorld"); final QName portName=new QName("http://bookworld.com","BookWorldPort"); final String address="http://localhost:" + PORT + "/bwsoap"; Service service=Service.create(serviceName); service.addPort(portName,SOAPBinding.SOAP11HTTP_BINDING,address); BookWorld bwService=service.getPort(BookWorld.class); BookWithValidation bw=bwService.echoBook(new BookWithValidation("WS","123")); assertEquals("123",bw.getId()); try { bwService.echoBook(new BookWithValidation(null,"123")); fail("Validation failure expected"); } catch ( SOAPFaultException ex) { } }

EqualityVerifier 
@Test public void testProgrammaticValidationPassesButParameterValidationFailesIfIdIsNull(){ final Response r=createWebClient("/jaxrs/bookstore/books").post(new Form().param("name","aa")); assertEquals(Status.BAD_REQUEST.getStatusCode(),r.getStatus()); }

Class: org.apache.cxf.systest.jaxrs.websocket.JAXRSClientConduitWebSocketTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testBookWithWebSocket() throws Exception { String address="ws://localhost:" + getPort() + "/websocket"; BookStoreWebSocket resource=JAXRSClientFactory.create(address,BookStoreWebSocket.class); Client client=WebClient.client(resource); client.header(HttpHeaders.USER_AGENT,JAXRSClientConduitWebSocketTest.class.getName()); assertEquals("CXF in Action",new String(resource.getBookName())); assertEquals("CXF in Action",new String(resource.getBookName())); Book book=resource.getBook(123); assertEquals("CXF in Action",book.getName()); assertEquals(Long.valueOf(123),resource.echoBookId(123)); assertEquals(Long.valueOf(123),resource.echoBookId(123)); }

APIUtilityVerifier EqualityVerifier 
@Test public void testCallsWithIDReferences() throws Exception { String address="ws://localhost:" + getPort() + "/websocket"; BookStoreWebSocket resource=JAXRSClientFactory.create(address,BookStoreWebSocket.class,null,true); Client client=WebClient.client(resource); client.header(HttpHeaders.USER_AGENT,JAXRSClientConduitWebSocketTest.class.getName()); EchoBookIdRunner[] runners=new EchoBookIdRunner[2]; runners[0]=new EchoBookIdRunner(resource,549); runners[1]=new EchoBookIdRunner(resource,495); new Thread(runners[0]).start(); new Thread(runners[1]).start(); long timetowait=5000; while (timetowait > 0) { if (runners[0].isCompleted() && runners[1].isCompleted()) { break; } Thread.sleep(500); timetowait-=500; } assertEquals(Long.valueOf(549),runners[0].getValue()); assertEquals(Long.valueOf(495),runners[1].getValue()); }

Class: org.apache.cxf.systest.jaxrs.websocket.JAXRSClientServerWebSocketSpringWebAppTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookHTTP() throws Exception { String address="http://localhost:" + getPort() + getContext()+ "/http/web/bookstore/books/1"; WebClient wc=WebClient.create(address); wc.accept("application/xml"); Book book=wc.get(Book.class); assertEquals(1L,book.getId()); }

Class: org.apache.cxf.systest.jaxrs.websocket.JAXRSClientServerWebSocketTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testBookWithWebSocketAndHTTP() throws Exception { String address="ws://localhost:" + getPort() + getContext()+ "/websocket/web/bookstore"; WebSocketTestClient wsclient=new WebSocketTestClient(address); wsclient.connect(); try { wsclient.sendMessage(("GET " + getContext() + "/websocket/web/bookstore/booknames").getBytes()); assertTrue("one book must be returned",wsclient.await(3)); List received=wsclient.getReceived(); assertEquals(1,received.size()); WebSocketTestClient.Response resp=new WebSocketTestClient.Response(received.get(0)); assertEquals(200,resp.getStatusCode()); assertEquals("text/plain",resp.getContentType()); String value=resp.getTextEntity(); assertEquals("CXF in Action",value); testGetBookHTTPFromWebSocketEndpoint(); } finally { wsclient.close(); } }

APIUtilityVerifier IterativeVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testGetBookStreamWithIDReferences() throws Exception { String address="ws://localhost:" + getPort() + getContext()+ "/websocket/web/bookstore"; WebSocketTestClient wsclient=new WebSocketTestClient(address); wsclient.connect(); try { wsclient.reset(5); String reqid=UUID.randomUUID().toString(); wsclient.sendMessage(("GET " + getContext() + "/websocket/web/bookstore/bookstream\r\nAccept: application/json\r\n"+ WebSocketConstants.DEFAULT_REQUEST_ID_KEY+ ": "+ reqid+ "\r\n\r\n").getBytes()); assertTrue("response expected",wsclient.await(5)); List received=wsclient.getReceivedResponses(); assertEquals(5,received.size()); WebSocketTestClient.Response resp=received.get(0); assertEquals(200,resp.getStatusCode()); assertEquals("application/json",resp.getContentType()); String value=resp.getTextEntity(); assertEquals(value,getBookJson(1)); for (int i=2; i <= 5; i++) { resp=received.get(i - 1); assertEquals(0,resp.getStatusCode()); assertEquals(reqid,resp.getId()); assertEquals(resp.getTextEntity(),getBookJson(i)); } } finally { wsclient.close(); } }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testCallsInParallel() throws Exception { String address="ws://localhost:" + getPort() + getContext()+ "/websocket/web/bookstore"; WebSocketTestClient wsclient=new WebSocketTestClient(address); wsclient.connect(); try { wsclient.reset(2); wsclient.sendTextMessage("GET " + getContext() + "/websocket/web/bookstore/hold/3000"); wsclient.sendTextMessage("GET " + getContext() + "/websocket/web/bookstore/hold/3000"); assertTrue("response expected",wsclient.await(4)); List received=wsclient.getReceivedResponses(); assertEquals(2,received.size()); } finally { wsclient.close(); } }

APIUtilityVerifier IterativeVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testGetBookStream() throws Exception { String address="ws://localhost:" + getPort() + getContext()+ "/websocket/web/bookstore"; WebSocketTestClient wsclient=new WebSocketTestClient(address); wsclient.connect(); try { wsclient.reset(5); wsclient.sendMessage(("GET " + getContext() + "/websocket/web/bookstore/bookstream\r\nAccept: application/json\r\n\r\n").getBytes()); assertTrue("response expected",wsclient.await(5)); List received=wsclient.getReceivedResponses(); assertEquals(5,received.size()); WebSocketTestClient.Response resp=received.get(0); assertEquals(200,resp.getStatusCode()); assertEquals("application/json",resp.getContentType()); String value=resp.getTextEntity(); assertEquals(value,getBookJson(1)); for (int i=2; i <= 5; i++) { resp=received.get(i - 1); assertEquals(0,resp.getStatusCode()); assertEquals(resp.getTextEntity(),getBookJson(i)); } } finally { wsclient.close(); } }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testWrongMethod() throws Exception { String address="ws://localhost:" + getPort() + getContext()+ "/websocket/web/bookstore"; WebSocketTestClient wsclient=new WebSocketTestClient(address); wsclient.connect(); try { wsclient.reset(1); wsclient.sendMessage(("POST " + getContext() + "/websocket/web/bookstore/booknames").getBytes()); assertTrue("error response expected",wsclient.await(3)); List received=wsclient.getReceivedResponses(); assertEquals(1,received.size()); WebSocketTestClient.Response resp=received.get(0); assertEquals(405,resp.getStatusCode()); } finally { wsclient.close(); } }

APIUtilityVerifier IterativeVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testBookWithWebSocket() throws Exception { String address="ws://localhost:" + getPort() + getContext()+ "/websocket/web/bookstore"; WebSocketTestClient wsclient=new WebSocketTestClient(address); wsclient.connect(); try { wsclient.sendMessage(("GET " + getContext() + "/websocket/web/bookstore/booknames").getBytes()); assertTrue("one book must be returned",wsclient.await(30000)); List received=wsclient.getReceivedResponses(); assertEquals(1,received.size()); WebSocketTestClient.Response resp=received.get(0); assertEquals(200,resp.getStatusCode()); assertEquals("text/plain",resp.getContentType()); String value=resp.getTextEntity(); assertEquals("CXF in Action",value); wsclient.reset(1); wsclient.sendTextMessage("GET " + getContext() + "/websocket/web/bookstore/booknames"); assertTrue("one book must be returned",wsclient.await(3)); received=wsclient.getReceivedResponses(); assertEquals(1,received.size()); resp=received.get(0); assertEquals(200,resp.getStatusCode()); assertEquals("text/plain",resp.getContentType()); value=resp.getTextEntity(); assertEquals("CXF in Action",value); wsclient.reset(1); wsclient.sendMessage(("GET " + getContext() + "/websocket/web/bookstore/books/123").getBytes()); assertTrue("response expected",wsclient.await(3)); received=wsclient.getReceivedResponses(); resp=received.get(0); assertEquals(200,resp.getStatusCode()); assertEquals("application/xml",resp.getContentType()); value=resp.getTextEntity(); assertTrue(value.startsWith("")); wsclient.reset(1); wsclient.sendMessage(("POST " + getContext() + "/websocket/web/bookstore/booksplain\r\nContent-Type: text/plain\r\n\r\n123").getBytes()); assertTrue("response expected",wsclient.await(3)); received=wsclient.getReceivedResponses(); resp=received.get(0); assertEquals(200,resp.getStatusCode()); assertEquals("text/plain",resp.getContentType()); value=resp.getTextEntity(); assertEquals("123",value); wsclient.reset(1); wsclient.sendTextMessage("POST " + getContext() + "/websocket/web/bookstore/booksplain\r\nContent-Type: text/plain\r\n\r\n123"); assertTrue("response expected",wsclient.await(3)); received=wsclient.getReceivedResponses(); resp=received.get(0); assertEquals(200,resp.getStatusCode()); assertEquals("text/plain",resp.getContentType()); value=resp.getTextEntity(); assertEquals("123",value); wsclient.reset(6); wsclient.sendMessage(("GET " + getContext() + "/websocket/web/bookstore/bookbought").getBytes()); assertTrue("response expected",wsclient.await(5)); received=wsclient.getReceivedResponses(); assertEquals(6,received.size()); resp=received.get(0); assertEquals(200,resp.getStatusCode()); assertEquals("application/octet-stream",resp.getContentType()); value=resp.getTextEntity(); assertTrue(value.startsWith("Today:")); for (int r=2, i=1; i < 6; r*=2, i++) { resp=received.get(i); assertEquals(0,resp.getStatusCode()); assertEquals(r,Integer.parseInt(resp.getTextEntity())); } } finally { wsclient.close(); } }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testStreamRegisterAndUnregister() throws Exception { String address="ws://localhost:" + getPort() + getContext()+ "/websocket/web/bookstore"; WebSocketTestClient wsclient1=new WebSocketTestClient(address); WebSocketTestClient wsclient2=new WebSocketTestClient(address); wsclient1.connect(); wsclient2.connect(); try { String regkey=UUID.randomUUID().toString(); EventCreatorRunner runner=new EventCreatorRunner(wsclient2,regkey,1000,1000); new Thread(runner).start(); wsclient1.reset(3); wsclient1.sendTextMessage("GET " + getContext() + "/websocket/web/bookstore/events/register\r\n"+ WebSocketConstants.DEFAULT_REQUEST_ID_KEY+ ": "+ regkey+ "\r\n\r\n"); assertFalse("only 2 responses expected",wsclient1.await(5)); List received=wsclient1.getReceivedResponses(); assertEquals(2,received.size()); WebSocketTestClient.Response resp=received.get(0); assertEquals(200,resp.getStatusCode()); assertEquals("text/plain",resp.getContentType()); String value=resp.getTextEntity(); assertTrue(value.startsWith("Registered " + regkey)); String id=resp.getId(); assertEquals("unexpected responseId",regkey,id); resp=received.get(1); assertEquals(0,resp.getStatusCode()); value=resp.getTextEntity(); assertEquals("News: event Hello created",value); id=resp.getId(); assertEquals("unexpected responseId",regkey,id); String[] values=runner.getValues(); assertTrue(runner.isCompleted()); assertEquals("Hello created",values[0]); assertTrue(values[1].startsWith("Unregistered: " + regkey)); assertEquals("Hola created",values[2]); } finally { wsclient1.close(); wsclient2.close(); } }

APIUtilityVerifier BranchVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCallsWithIDReferences() throws Exception { String address="ws://localhost:" + getPort() + getContext()+ "/websocket/web/bookstore"; WebSocketTestClient wsclient=new WebSocketTestClient(address); wsclient.connect(); try { wsclient.sendTextMessage("POST " + getContext() + "/websocket/web/bookstore/booksplain\r\nContent-Type: text/plain\r\n\r\n459"); assertTrue("response expected",wsclient.await(3)); List received=wsclient.getReceivedResponses(); WebSocketTestClient.Response resp=received.get(0); assertEquals(200,resp.getStatusCode()); assertEquals("text/plain",resp.getContentType()); String value=resp.getTextEntity(); assertEquals("459",value); String id=resp.getId(); assertNull("response id is incorrect",id); wsclient.reset(2); String reqid1=UUID.randomUUID().toString(); String reqid2=UUID.randomUUID().toString(); wsclient.sendTextMessage("POST " + getContext() + "/websocket/web/bookstore/booksplain\r\nContent-Type: text/plain\r\n"+ WebSocketConstants.DEFAULT_REQUEST_ID_KEY+ ": "+ reqid1+ "\r\n\r\n549"); wsclient.sendTextMessage("POST " + getContext() + "/websocket/web/bookstore/booksplain\r\nContent-Type: text/plain\r\n"+ WebSocketConstants.DEFAULT_REQUEST_ID_KEY+ ": "+ reqid2+ "\r\n\r\n495"); assertTrue("response expected",wsclient.await(3)); received=wsclient.getReceivedResponses(); for ( WebSocketTestClient.Response r : received) { assertEquals(200,r.getStatusCode()); assertEquals("text/plain",r.getContentType()); value=r.getTextEntity(); id=r.getId(); if (reqid1.equals(id)) { assertEquals("549",value); } else if (reqid2.equals(id)) { assertEquals("495",value); } else { fail("unexpected responseId: " + id); } } } finally { wsclient.close(); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetBookHTTPFromWebSocketEndpoint() throws Exception { String address="http://localhost:" + getPort() + getContext()+ "/websocket/web/bookstore/books/1"; WebClient wc=WebClient.create(address); wc.accept("application/xml"); Book book=wc.get(Book.class); assertEquals(1L,book.getId()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testBookWithWebSocketServletStream() throws Exception { String address="ws://localhost:" + getPort() + getContext()+ "/websocket/web/bookstore"; WebSocketTestClient wsclient=new WebSocketTestClient(address); wsclient.connect(); try { wsclient.sendMessage(("GET " + getContext() + "/websocket/web/bookstore/booknames/servletstream").getBytes()); assertTrue("one book must be returned",wsclient.await(3)); List received=wsclient.getReceivedResponses(); assertEquals(1,received.size()); WebSocketTestClient.Response resp=received.get(0); assertEquals(200,resp.getStatusCode()); assertEquals("text/plain",resp.getContentType()); String value=resp.getTextEntity(); assertEquals("CXF in Action",value); } finally { wsclient.close(); } }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testPathRestriction() throws Exception { String address="ws://localhost:" + getPort() + getContext()+ "/websocket/web/bookstore"; WebSocketTestClient wsclient=new WebSocketTestClient(address); wsclient.connect(); try { wsclient.sendMessage(("GET " + getContext() + "/websocket/bookstore2").getBytes()); assertTrue("error response expected",wsclient.await(3)); List received=wsclient.getReceivedResponses(); assertEquals(1,received.size()); WebSocketTestClient.Response resp=received.get(0); assertEquals(400,resp.getStatusCode()); } finally { wsclient.close(); } }

Class: org.apache.cxf.systest.jaxws.AnyClientServerTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAny() throws Exception { URL wsdl=getClass().getResource("/wsdl/any.wsdl"); assertNotNull(wsdl); SOAPService ss=new SOAPService(wsdl,serviceName); Greeter port=ss.getSoapPort(); updateAddressPort(port,PORT); List any=new ArrayList(); Port anyPort=new Port(); Port anyPort1=new Port(); JAXBElement ele1=new JAXBElement(new QName("http://apache.org/hello_world_soap_http/other","port"),String.class,"hello"); anyPort.setAny(ele1); JAXBElement ele2=new JAXBElement(new QName("http://apache.org/hello_world_soap_http/other","port"),String.class,"Bon"); anyPort1.setAny(ele2); any.add(anyPort); any.add(anyPort1); String rep=port.sayHi(any); assertEquals(rep,"helloBon"); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testList() throws Exception { URL wsdl=getClass().getResource("/wsdl/any.wsdl"); assertNotNull(wsdl); SOAPService ss=new SOAPService(wsdl,serviceName); Greeter port=ss.getSoapPort(); updateAddressPort(port,PORT); List list=new ArrayList(); org.apache.hello_world_soap_http.any_types.SayHi1.Port port1=new org.apache.hello_world_soap_http.any_types.SayHi1.Port(); port1.setRequestType("hello"); org.apache.hello_world_soap_http.any_types.SayHi1.Port port2=new org.apache.hello_world_soap_http.any_types.SayHi1.Port(); port2.setRequestType("Bon"); list.add(port1); list.add(port2); String rep=port.sayHi1(list); assertEquals(rep,"helloBon"); }

Class: org.apache.cxf.systest.jaxws.CXF6655Test

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testConnection() throws Exception { QName serviceName=new QName("http://cxf.apache.org/systest/jaxws/","HelloService"); HelloService service=new HelloService(null,serviceName); assertNotNull(service); Hello hello=service.getHelloPort(); ((BindingProvider)hello).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,"http://localhost:" + PORT + "/hello"); assertEquals("getSayHi",hello.sayHi("SayHi")); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testConnectionWithProxy() throws Exception { QName serviceName=new QName("http://cxf.apache.org/systest/jaxws/","HelloService"); HelloService service=new HelloService(null,serviceName); assertNotNull(service); Hello hello=service.getHelloPort(); Client client=ClientProxy.getClient(hello); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); HTTPConduit http=(HTTPConduit)client.getConduit(); HTTPClientPolicy httpClientPolicy=new HTTPClientPolicy(); httpClientPolicy.setAllowChunking(false); httpClientPolicy.setReceiveTimeout(0); httpClientPolicy.setProxyServerType(ProxyServerType.HTTP); httpClientPolicy.setProxyServer("localhost"); httpClientPolicy.setProxyServerPort(PROXY_PORT); http.setClient(httpClientPolicy); ((BindingProvider)hello).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,"http://localhost:" + PORT + "/hello"); assertEquals("getSayHi",hello.sayHi("SayHi")); }

Class: org.apache.cxf.systest.jaxws.ClientServerGreeterBaseNoWsdlTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testInvocation() throws Exception { GreeterService service=new GreeterService(); assertNotNull(service); try { Greeter greeter=service.getGreeterPort(); updateAddressPort(greeter,PORT); String greeting=greeter.greetMe("Bonjour"); assertNotNull("no response received from service",greeting); assertEquals("Hello Bonjour",greeting); } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

Class: org.apache.cxf.systest.jaxws.ClientServerGreeterBaseTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testInvocation() throws Exception { GreeterService service=new GreeterService(); assertNotNull(service); try { Greeter greeter=service.getGreeterPort(); updateAddressPort(greeter,PORT); String greeting=greeter.greetMe("Bonjour"); assertNotNull("no response received from service",greeting); assertEquals("Hello Bonjour",greeting); } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

Class: org.apache.cxf.systest.jaxws.ClientServerGreeterNoWsdlTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testInvocation() throws Exception { GreeterService service=new GreeterService(); assertNotNull(service); try { Greeter greeter=service.getGreeterPort(); updateAddressPort(greeter,PORT); String greeting=greeter.greetMe("Bonjour"); assertNotNull("no response received from service",greeting); assertEquals("Hello Bonjour",greeting); } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

Class: org.apache.cxf.systest.jaxws.ClientServerMiscTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSimpleClientWithWsdl() throws Exception { QName portName=new QName("http://cxf.apache.org/systest/jaxws/DocLitWrappedCodeFirstService","DocLitWrappedCodeFirstServicePort"); QName servName=new QName("http://cxf.apache.org/systest/jaxws/DocLitWrappedCodeFirstService","DocLitWrappedCodeFirstService"); ClientProxyFactoryBean factory=new ClientProxyFactoryBean(); factory.setWsdlURL(ServerMisc.DOCLIT_CODEFIRST_URL + "?wsdl"); factory.setServiceName(servName); factory.setServiceClass(DocLitWrappedCodeFirstService.class); factory.setEndpointName(portName); DocLitWrappedCodeFirstService port=(DocLitWrappedCodeFirstService)factory.create(); assertNotNull(port); String echoMsg=port.echo("Hello"); assertEquals("Hello",echoMsg); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testRefAnonymousComplexType() throws Exception { AnonymousComplexTypeService actService=new AnonymousComplexTypeService(); assertNotNull(actService); QName portName=new QName("http://cxf.apache.org/anonymous_complex_type/","anonymous_complex_typeSOAP"); AnonymousComplexType act=actService.getPort(portName,AnonymousComplexType.class); updateAddressPort(act,PORT); try { SplitName name=new SplitName(); name.setName("Tom Li"); RefSplitName refName=new RefSplitName(); refName.setSplitName(name); RefSplitNameResponse reply=act.refSplitName(refName); assertNotNull("no response received from service",reply); assertEquals("Tom",reply.getSplitNameResponse().getNames().getFirst()); assertEquals("Li",reply.getSplitNameResponse().getNames().getSecond()); } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testMinOccursAndNillableJAXBElement() throws Exception { JaxbElementTest_Service service=new JaxbElementTest_Service(); assertNotNull(service); JaxbElementTest port=service.getPort(JaxbElementTest.class); updateAddressPort(port,PORT); try { String response=port.newOperation("hello"); assertNotNull(response); assertEquals("in=hello",response); response=port.newOperation(null); assertNotNull(response); assertEquals("in=null",response); } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

InternalCallVerifier EqualityVerifier 
@Test public void testWSDLDocs() throws Exception { Map ns=new HashMap(); ns.put("wsdl",WSDLConstants.NS_WSDL11); XPathUtils xpu=new XPathUtils(ns); Document wsdl=StaxUtils.read(this.getHttpConnection(ServerMisc.DOCLIT_CODEFIRST_URL + "?wsdl").getInputStream()); assertEquals("DocLitWrappedCodeFirstService impl",xpu.getValue("/wsdl:definitions/wsdl:service/wsdl:documentation",wsdl.getDocumentElement(),XPathConstants.STRING)); assertEquals("DocLitWrappedCodeFirstService interface",xpu.getValue("/wsdl:definitions/wsdl:portType/wsdl:documentation",wsdl.getDocumentElement(),XPathConstants.STRING)); assertEquals("DocLitWrappedCodeFirstService top level doc",xpu.getValue("/wsdl:definitions/wsdl:documentation",wsdl.getDocumentElement(),XPathConstants.STRING)); assertEquals("DocLitWrappedCodeFirstService binding doc",xpu.getValue("/wsdl:definitions/wsdl:binding/wsdl:documentation",wsdl.getDocumentElement(),XPathConstants.STRING)); assertEquals("DocLitWrappedCodeFirstService service/port doc",xpu.getValue("/wsdl:definitions/wsdl:service/wsdl:port/wsdl:documentation",wsdl.getDocumentElement(),XPathConstants.STRING)); assertEquals("multiInOut doc",xpu.getValue("/wsdl:definitions/wsdl:portType/wsdl:operation[@name='multiInOut']" + "/wsdl:documentation",wsdl.getDocumentElement(),XPathConstants.STRING)); assertEquals("multiInOut Input doc",xpu.getValue("/wsdl:definitions/wsdl:portType/wsdl:operation[@name='multiInOut']" + "/wsdl:input/wsdl:documentation",wsdl.getDocumentElement(),XPathConstants.STRING)); assertEquals("multiInOut Output doc",xpu.getValue("/wsdl:definitions/wsdl:portType/wsdl:operation[@name='multiInOut']" + "/wsdl:output/wsdl:documentation",wsdl.getDocumentElement(),XPathConstants.STRING)); assertEquals("multiInOut InputMessage doc",xpu.getValue("/wsdl:definitions/wsdl:message[@name='multiInOut']" + "/wsdl:documentation",wsdl.getDocumentElement(),XPathConstants.STRING)); assertEquals("multiInOut OutputMessage doc",xpu.getValue("/wsdl:definitions/wsdl:message[@name='multiInOutResponse']" + "/wsdl:documentation",wsdl.getDocumentElement(),XPathConstants.STRING)); assertEquals("multiInOut binding doc",xpu.getValue("/wsdl:definitions/wsdl:binding/wsdl:operation[@name='multiInOut']" + "/wsdl:documentation",wsdl.getDocumentElement(),XPathConstants.STRING)); assertEquals("multiInOut binding Input doc",xpu.getValue("/wsdl:definitions/wsdl:binding/wsdl:operation[@name='multiInOut']" + "/wsdl:input/wsdl:documentation",wsdl.getDocumentElement(),XPathConstants.STRING)); assertEquals("multiInOut binding Output doc",xpu.getValue("/wsdl:definitions/wsdl:binding/wsdl:operation[@name='multiInOut']" + "/wsdl:output/wsdl:documentation",wsdl.getDocumentElement(),XPathConstants.STRING)); assertEquals("fault binding doc",xpu.getValue("/wsdl:definitions/wsdl:binding/wsdl:operation[@name='throwException']" + "/wsdl:fault/wsdl:documentation",wsdl.getDocumentElement(),XPathConstants.STRING)); assertEquals("fault porttype doc",xpu.getValue("/wsdl:definitions/wsdl:portType/wsdl:operation[@name='throwException']" + "/wsdl:fault/wsdl:documentation",wsdl.getDocumentElement(),XPathConstants.STRING)); assertEquals("fault message doc",xpu.getValue("/wsdl:definitions/wsdl:message[@name='CustomException']" + "/wsdl:documentation",wsdl.getDocumentElement(),XPathConstants.STRING)); }

EqualityVerifier 
@Test public void testWrappedHolderOutNull() throws Exception { QName portName=new QName("http://cxf.apache.org/systest/jaxws/DocLitWrappedCodeFirstService","DocLitWrappedCodeFirstServicePort"); QName servName=new QName("http://cxf.apache.org/systest/jaxws/DocLitWrappedCodeFirstService","DocLitWrappedCodeFirstService"); Service service=Service.create(new URL(ServerMisc.DOCLIT_CODEFIRST_URL + "?wsdl"),servName); DocLitWrappedCodeFirstService port=service.getPort(portName,DocLitWrappedCodeFirstService.class); Holder created=new Holder(); port.singleInOut(created); assertEquals(created.value,Boolean.FALSE); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAnonymousComplexType() throws Exception { AnonymousComplexTypeService actService=new AnonymousComplexTypeService(); assertNotNull(actService); QName portName=new QName("http://cxf.apache.org/anonymous_complex_type/","anonymous_complex_typeSOAP"); AnonymousComplexType act=actService.getPort(portName,AnonymousComplexType.class); updateAddressPort(act,PORT); try { Names reply=act.splitName("Tom Li"); assertNotNull("no response received from service",reply); assertEquals("Tom",reply.getFirst()); assertEquals("Li",reply.getSecond()); } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testInheritedTypesInOtherPackage() throws Exception { InheritService serv=new InheritService(); Inherit port=serv.getInheritPort(); updateAddressPort(port,PORT); ObjectInfo obj=port.getObject(0); assertNotNull(obj); assertNotNull(obj.getBaseObject()); assertEquals("A",obj.getBaseObject().getName()); assertTrue(obj.getBaseObject() instanceof SubTypeA); obj=port.getObject(1); assertNotNull(obj); assertNotNull(obj.getBaseObject()); assertEquals("B",obj.getBaseObject().getName()); assertTrue(obj.getBaseObject() instanceof SubTypeB); }

EqualityVerifier NullVerifier HybridVerifier 
@Test public void testOrderedParamHolder() throws Exception { OrderedParamHolder_Service service=new OrderedParamHolder_Service(); OrderedParamHolder port=service.getOrderedParamHolderSOAP(); updateAddressPort(port,PORT); try { Holder part3=new Holder(); part3.value=new ComplexStruct(); part3.value.setElem1("elem1"); part3.value.setElem2("elem2"); part3.value.setElem3(0); Holder part2=new Holder(); part2.value=0; Holder part1=new Holder(); part1.value="part1"; port.orderedParamHolder(part3,part2,part1); assertNotNull(part3.value); assertEquals("check value","return elem1",part3.value.getElem1()); assertEquals("check value","return elem2",part3.value.getElem2()); assertEquals("check value",1,part3.value.getElem3()); assertNotNull(part2.value); assertEquals("check value",1,part2.value.intValue()); assertNotNull(part1.value); assertEquals("check value","return part1",part1.value); } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

APIUtilityVerifier IterativeVerifier BranchVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testCXF5064() throws Exception { URL url=new URL(ServerMisc.CXF_5064_URL + "?wsdl"); HttpURLConnection con=(HttpURLConnection)url.openConnection(); con.getResponseCode(); String str=IOUtils.readStringFromStream(con.getInputStream()); BufferedReader reader=new BufferedReader(new StringReader(str)); String s=reader.readLine(); while (s != null) { if (s.contains("SESSIONID") && s.contains("element ")) { assertTrue(s.contains("string")); assertFalse(s.contains("headerObj")); } s=reader.readLine(); } QName name=new QName("http://cxf.apache.org/cxf5064","SOAPHeaderServiceImplService"); Service service=Service.create(name); service.addPort(name,SOAPBinding.SOAP11HTTP_BINDING,ServerMisc.CXF_5064_URL); SOAPHeaderSEI port=service.getPort(name,SOAPHeaderSEI.class); assertEquals("a-b",port.test(new HeaderObj("a-b"))); service=Service.create(url,name); port=service.getPort(SOAPHeaderSEI.class); assertEquals("a-b",port.test(new HeaderObj("a-b"))); }

APIUtilityVerifier UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDocLitBare() throws Exception { QName portName=new QName("http://cxf.apache.org/systest/jaxws/DocLitBareCodeFirstService","DocLitBareCodeFirstServicePort"); QName servName=new QName("http://cxf.apache.org/systest/jaxws/DocLitBareCodeFirstService","DocLitBareCodeFirstService"); Service service=Service.create(servName); service.addPort(portName,SOAPBinding.SOAP11HTTP_BINDING,ServerMisc.DOCLITBARE_CODEFIRST_URL); DocLitBareCodeFirstService port=service.getPort(portName,DocLitBareCodeFirstService.class); DocLitBareCodeFirstService.GreetMeRequest req=new DocLitBareCodeFirstService.GreetMeRequest(); DocLitBareCodeFirstService.GreetMeResponse resp; BigInteger i[]; req.setName("Foo"); resp=port.greetMe(req); assertEquals(req.getName(),resp.getName()); i=port.sayTest(new DocLitBareCodeFirstService.SayTestRequest("Dan")); assertEquals(4,i.length); assertEquals(0,i[0].intValue()); assertEquals(1,i[1].intValue()); assertEquals(2,i[2].intValue()); assertEquals(3,i[3].intValue()); service=Service.create(new URL(ServerMisc.DOCLITBARE_CODEFIRST_URL + "?wsdl"),servName); port=service.getPort(portName,DocLitBareCodeFirstService.class); resp=port.greetMe(req); assertEquals(req.getName(),resp.getName()); req.setName("fault"); try { resp=port.greetMe(req); fail("did not get fault back"); } catch ( SOAPFaultException ex) { assertEquals("mr.actor",ex.getFault().getFaultActor()); assertEquals("test",ex.getFault().getDetail().getFirstChild().getLocalName()); } req.setName("emptyfault"); try { resp=port.greetMe(req); fail("did not get fault back"); } catch ( SOAPFaultException ex) { assertNull(ex.getFault().getDetail()); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAnonymousMinOccursConfig() throws Exception { HttpURLConnection httpConnection=getHttpConnection(ServerMisc.DOCLIT_CODEFIRST_SETTINGS_URL + "?wsdl"); httpConnection.connect(); assertEquals(200,httpConnection.getResponseCode()); assertEquals("OK",httpConnection.getResponseMessage()); InputStream in=httpConnection.getInputStream(); assertNotNull(in); Document doc=StaxUtils.read(in); assertNotNull(doc); Map ns=new HashMap(); ns.put("soap",Soap11.SOAP_NAMESPACE); ns.put("tns","http://cxf.apache.org/systest/jaxws/DocLitWrappedCodeFirstService"); ns.put("wsdl","http://schemas.xmlsoap.org/wsdl/"); ns.put("xs","http://www.w3.org/2001/XMLSchema"); XPathUtils xu=new XPathUtils(ns); Node ct=(Node)xu.getValue("//wsdl:definitions/wsdl:types/xs:schema" + "/xs:element[@name='getFooSetResponse']/xs:complexType/xs:sequence",doc,XPathConstants.NODE); assertNotNull(ct); ct=(Node)xu.getValue("//wsdl:definitions/wsdl:types/xs:schema" + "/xs:element[@name='multiInOut']/xs:complexType/xs:sequence" + "/xs:element[@nillable='true']",doc,XPathConstants.NODE); assertNotNull(ct); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testInterfaceExtension() throws Exception { QName portName=new QName("http://cxf.apache.org/systest/jaxws/DocLitWrappedCodeFirstBaseService","DocLitWrappedCodeFirstBaseServicePort"); QName servName=new QName("http://cxf.apache.org/systest/jaxws/DocLitWrappedCodeFirstBaseService","DocLitWrappedCodeFirstBaseService"); Service service=Service.create(servName); service.addPort(portName,SOAPBinding.SOAP11HTTP_BINDING,ServerMisc.DOCLIT_CODEFIRST_BASE_URL); DocLitWrappedCodeFirstBaseService port=service.getPort(portName,DocLitWrappedCodeFirstBaseService.class); assertEquals(1,port.operationInBase(1)); assertEquals(2,port.operationInSub1(2)); assertEquals(3,port.operationInSub2(3)); service=Service.create(new URL(ServerMisc.DOCLIT_CODEFIRST_BASE_URL + "?wsdl"),servName); port=service.getPort(portName,DocLitWrappedCodeFirstBaseService.class); assertEquals(1,port.operationInBase(1)); assertEquals(2,port.operationInSub1(2)); assertEquals(3,port.operationInSub2(3)); }

Class: org.apache.cxf.systest.jaxws.ClientServerMixedStyleTest

UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testMixedStyle() throws Exception { SOAPService service=new SOAPService(); assertNotNull(service); try { Greeter greeter=service.getPort(portName,Greeter.class); updateAddressPort(greeter,PORT); GreetMe1 request=new GreetMe1(); request.setRequestType("Bonjour"); GreetMeResponse greeting=greeter.greetMe(request); assertNotNull("no response received from service",greeting); assertEquals("Hello Bonjour",greeting.getResponseType()); String reply=greeter.sayHi(); assertNotNull("no response received from service",reply); assertEquals("Bonjour",reply); try { greeter.pingMe(); fail("expected exception not caught"); } catch ( org.apache.hello_world_mixedstyle.PingMeFault f) { } } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testCXF885() throws Exception { Service serv=Service.create(new QName("http://example.com","MixedTest")); MixedTest test=serv.getPort(MixedTest.class); ((BindingProvider)test).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,"http://localhost:" + PORT + "/cxf885"); String ret=test.hello("A","B"); assertEquals("Hello A and B",ret); String ret2=test.simple("Dan"); assertEquals("Hello Dan",ret2); String ret3=test.tripple("A","B","C"); assertEquals("Tripple: A B C",ret3); String ret4=test.simple2(24); assertEquals("Int: 24",ret4); serv=Service.create(new URL("http://localhost:" + PORT + "/cxf885?wsdl"),new QName("http://example.com","MixedTestImplService")); test=serv.getPort(new QName("http://example.com","MixedTestImplPort"),MixedTest.class); ret=test.hello("A","B"); assertEquals("Hello A and B",ret); ret2=test.simple("Dan"); assertEquals("Hello Dan",ret2); ret3=test.tripple("A","B","C"); assertEquals("Tripple: A B C",ret3); ret4=test.simple2(24); assertEquals("Int: 24",ret4); }

Class: org.apache.cxf.systest.jaxws.ClientServerPartialWsdlTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCXF4676Partial1() throws Exception { DynamicClientFactory dcf=DynamicClientFactory.newInstance(); Client client=dcf.createClient("http://localhost:" + PORT + "/AddNumbersImplPartial1Service?wsdl",serviceName1,portName1); updateAddressPort(client,PORT); Object[] result=client.invoke("addTwoNumbers",10,20); assertNotNull("no response received from service",result); assertEquals(30,result[0]); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCXF4676partial2() throws Exception { DynamicClientFactory dcf=DynamicClientFactory.newInstance(); Client client=dcf.createClient("http://localhost:" + PORT + "/AddNumbersImplPartial2Service?wsdl",serviceName2,portName2); updateAddressPort(client,PORT); Object[] result=client.invoke("addTwoNumbers",10,20); assertNotNull("no response received from service",result); assertEquals(30,result[0]); }

Class: org.apache.cxf.systest.jaxws.ClientServerRPCLitDefatulAnnoTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBasicConnection() throws Exception { QName serviceName=new QName("http://cxf.apache.org/systest/jaxws/","HelloService"); HelloService service=new HelloService(getClass().getResource("/wsdl/others/hello.wsdl"),serviceName); assertNotNull(service); Hello hello=service.getHelloPort(); updateAddressPort(hello,PORT); assertEquals("getSayHi",hello.sayHi("SayHi")); }

Class: org.apache.cxf.systest.jaxws.ClientServerRPCLitTest

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testComplexType() throws Exception { SOAPServiceRPCLit service=new SOAPServiceRPCLit(); assertNotNull(service); GreeterRPCLit greeter=service.getPort(portName,GreeterRPCLit.class); updateAddressPort(greeter,PORT); MyComplexStruct in=new MyComplexStruct(); in.setElem1("elem1"); in.setElem2("elem2"); in.setElem3(45); try { ((BindingProvider)greeter).getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED,Boolean.TRUE); MyComplexStruct out=greeter.sendReceiveData(in); assertNotNull("no response received from service",out); assertEquals(in.getElem1(),out.getElem1()); assertEquals(in.getElem2(),out.getElem2()); assertEquals(in.getElem3(),out.getElem3()); } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } try { in.setElem2("invalid"); greeter.sendReceiveData(in); } catch ( SOAPFaultException f) { assertTrue(f.getCause() instanceof UnmarshalException); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testNoElementParts() throws Exception { HttpURLConnection httpConnection=getHttpConnection("http://localhost:" + PORT + "/TestRPCWsdl?wsdl"); httpConnection.connect(); assertEquals(200,httpConnection.getResponseCode()); assertEquals("OK",httpConnection.getResponseMessage()); InputStream in=httpConnection.getInputStream(); assertNotNull(in); Document doc=StaxUtils.read(in); assertNotNull(doc); Map ns=new HashMap(); ns.put("soap",Soap11.SOAP_NAMESPACE); ns.put("wsdl","http://schemas.xmlsoap.org/wsdl/"); ns.put("xs","http://www.w3.org/2001/XMLSchema"); XPathUtils xu=new XPathUtils(ns); NodeList ct=(NodeList)xu.getValue("//wsdl:definitions/wsdl:message/wsdl:part[@element != '']",doc,XPathConstants.NODESET); assertNotNull(ct); assertEquals(0,ct.getLength()); ct=(NodeList)xu.getValue("//wsdl:definitions/wsdl:message/wsdl:part[@type != '']",doc,XPathConstants.NODESET); assertEquals(4,ct.getLength()); }

IterativeVerifier UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBasicConnection() throws Exception { SOAPServiceRPCLit service=new SOAPServiceRPCLit(); assertNotNull(service); String response1=new String("Hello Milestone-"); String response2=new String("Bonjour"); try { GreeterRPCLit greeter=service.getPort(portName,GreeterRPCLit.class); ClientProxy.getClient(greeter).getInInterceptors().add(new LoggingInInterceptor()); updateAddressPort(greeter,PORT); for (int idx=0; idx < 1; idx++) { String greeting=greeter.greetMe("Milestone-" + idx); assertNotNull("no response received from service",greeting); String exResponse=response1 + idx; assertEquals(exResponse,greeting); String reply=greeter.sayHi(); assertNotNull("no response received from service",reply); assertEquals(response2,reply); try { greeter.greetMe("return null"); fail("should catch WebServiceException"); } catch ( WebServiceException e) { } catch ( Exception e) { fail("should catch WebServiceException"); throw e; } try { greeter.greetMe(null); fail("should catch WebServiceException"); } catch ( WebServiceException e) { } catch ( Exception e) { fail("should catch WebServiceException"); throw e; } } } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

Class: org.apache.cxf.systest.jaxws.ClientServerTest

UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testFaultStackTrace() throws Exception { System.setProperty("cxf.config.file.url",getClass().getResource("fault-stack-trace.xml").toString()); URL wsdl=getClass().getResource("/wsdl/hello_world.wsdl"); assertNotNull(wsdl); SOAPService service=new SOAPService(wsdl,serviceName); ExecutorService ex=Executors.newFixedThreadPool(1); service.setExecutor(ex); assertNotNull(service); Greeter greeter=service.getPort(portName,Greeter.class); updateAddressPort(greeter,PORT); try { greeter.testDocLitFault(""); fail("Should have thrown Runtime exception"); } catch ( WebServiceException e) { assertEquals("can't get back original message","Unknown source",e.getCause().getMessage()); assertTrue(e.getCause().getStackTrace().length > 0); } }

InternalCallVerifier EqualityVerifier 
@Test public void testCXF2419() throws Exception { org.apache.cxf.hello_world.elrefs.SOAPService serv=new org.apache.cxf.hello_world.elrefs.SOAPService(); org.apache.cxf.hello_world.elrefs.Greeter g=serv.getSoapPort(); updateAddressPort(g,PORT); assertEquals("Hello CXF",g.greetMe("CXF")); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAddPortWithSpecifiedSoap12Binding() throws Exception { Service service=Service.create(serviceName); service.addPort(fakePortName,javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING,"http://localhost:" + PORT + "/SoapContext/SoapPort"); Greeter greeter=service.getPort(fakePortName,Greeter.class); String response=new String("Bonjour"); try { greeter.greetMe("test"); String reply=greeter.sayHi(); assertNotNull("no response received from service",reply); assertEquals(response,reply); } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testMultiPorts() throws Exception { URL wsdl=getClass().getResource("/wsdl/hello_world.wsdl"); assertNotNull(wsdl); QName sname=new QName("http://apache.org/hello_world_soap_http","SOAPServiceMultiPortTypeTest"); SOAPServiceMultiPortTypeTest service=new SOAPServiceMultiPortTypeTest(wsdl,sname); DocLitBare b=service.getDocLitBarePort(); updateAddressPort(b,PORT); BareDocumentResponse resp=b.testDocLitBare("CXF"); assertNotNull(resp); assertEquals("CXF",resp.getCompany()); Greeter g=service.getGreeterPort(); updateAddressPort(g,PORT); String result=g.greetMe("CXF"); assertEquals("Hello CXF",result); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAsyncDiscardProxy() throws Exception { URL wsdl=getClass().getResource("/wsdl/hello_world.wsdl"); assertNotNull(wsdl); SOAPService service=new SOAPService(wsdl,serviceName); assertNotNull(service); Greeter greeter=service.getPort(portName,Greeter.class); assertNotNull(service); updateAddressPort(greeter,PORT); Response r1=greeter.greetMeLaterAsync(3000); greeter=null; service=null; System.gc(); System.gc(); System.gc(); assertEquals("Hello, finally!",r1.get().getResponseType()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testBasicAuth() throws Exception { Service service=Service.create(serviceName); service.addPort(fakePortName,"http://schemas.xmlsoap.org/soap/","http://localhost:" + PORT + "/SoapContext/SoapPort"); Greeter greeter=service.getPort(fakePortName,Greeter.class); try { BindingProvider bp=(BindingProvider)greeter; bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY,"BJ"); bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY,"pswd"); String s=greeter.greetMe("secure"); assertEquals("Hello BJ",s); bp.getRequestContext().remove(BindingProvider.USERNAME_PROPERTY); bp.getRequestContext().remove(BindingProvider.PASSWORD_PROPERTY); Client client=ClientProxy.getClient(greeter); HTTPConduit httpConduit=(HTTPConduit)client.getConduit(); AuthorizationPolicy policy=new AuthorizationPolicy(); policy.setUserName("BJ2"); policy.setPassword("pswd"); httpConduit.setAuthorization(policy); s=greeter.greetMe("secure"); assertEquals("Hello BJ2",s); } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAddPortWithSpecifiedSoap11Binding() throws Exception { Service service=Service.create(serviceName); service.addPort(fakePortName,javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING,"http://localhost:" + PORT + "/SoapContext/SoapPort"); Greeter greeter=service.getPort(fakePortName,Greeter.class); String response=new String("Bonjour"); try { greeter.greetMe("test"); String reply=greeter.sayHi(); assertNotNull("no response received from service",reply); assertEquals(response,reply); } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

APIUtilityVerifier EqualityVerifier 
@Test public void testEchoProviderAsyncDecoupledEndpoints() throws Exception { String requestString=""; Service service=Service.create(serviceName); service.addPort(fakePortName,javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING,"http://localhost:" + PORT + "/SoapContext/AsyncEchoProvider"); Dispatch dispatcher=service.createDispatch(fakePortName,StreamSource.class,Service.Mode.PAYLOAD); Client client=((DispatchImpl)dispatcher).getClient(); WSAddressingFeature wsAddressingFeature=new WSAddressingFeature(); wsAddressingFeature.initialize(client,client.getBus()); dispatcher.getRequestContext().put("org.apache.cxf.ws.addressing.replyto","http://localhost:" + CLIENT_PORT + "/SoapContext/AsyncEchoClient"); StreamSource request=new StreamSource(new ByteArrayInputStream(requestString.getBytes())); StreamSource response=dispatcher.invoke(request); assertEquals(requestString,StaxUtils.toString(response)); }

APIUtilityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetWSDLWithGzip() throws Exception { String url="http://localhost:" + PORT + "/SoapContext/SoapPortWithGzip?wsdl"; HttpURLConnection httpConnection=getHttpConnection(url); httpConnection.setRequestProperty("Accept-Encoding","gzip, deflate"); httpConnection.connect(); assertEquals(200,httpConnection.getResponseCode()); assertEquals("text/xml;charset=utf-8",stripSpaces(httpConnection.getContentType().toLowerCase())); assertEquals("OK",httpConnection.getResponseMessage()); assertEquals("gzip",httpConnection.getContentEncoding()); InputStream in=httpConnection.getInputStream(); assertNotNull(in); GZIPInputStream inputStream=new GZIPInputStream(in); Document doc=StaxUtils.read(inputStream); assertNotNull(doc); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDynamicClientFactory() throws Exception { URL wsdl=getClass().getResource("/wsdl/hello_world.wsdl"); assertNotNull(wsdl); String wsdlUrl=null; wsdlUrl=wsdl.toURI().toString(); DynamicClientFactory dcf=DynamicClientFactory.newInstance(); Client client=dcf.createClient(wsdlUrl,serviceName,portName); updateAddressPort(client,PORT); client.invoke("greetMe","test"); Object[] result=client.invoke("sayHi"); assertNotNull("no response received from service",result); assertEquals("Bonjour",result[0]); Map jaxbContextProperties=new HashMap(); jaxbContextProperties.put("com.sun.xml.bind.defaultNamespaceRemap","uri:ultima:thule"); dcf.setJaxbContextProperties(jaxbContextProperties); client=dcf.createClient(wsdlUrl,serviceName,portName); updateAddressPort(client,PORT); client.invoke("greetMe","test"); result=client.invoke("sayHi"); assertNotNull("no response received from service",result); assertEquals("Bonjour",result[0]); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDocLitBareConnection() throws Exception { SOAPServiceDocLitBare service=new SOAPServiceDocLitBare(); assertNotNull(service); DocLitBare greeter=service.getPort(portName1,DocLitBare.class); updateAddressPort(greeter,BARE_PORT); try { BareDocumentResponse bareres=greeter.testDocLitBare("MySimpleDocument"); assertNotNull("no response for operation testDocLitBare",bareres); assertEquals("CXF",bareres.getCompany()); assertTrue(bareres.getId() == 1); } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testNillable() throws Exception { SOAPService service=new SOAPService(); assertNotNull(service); Greeter greeter=service.getPort(portName,Greeter.class); updateAddressPort(greeter,PORT); try { String reply=greeter.testNillable("test",100); assertEquals("test",reply); reply=greeter.testNillable(null,100); assertNull(reply); } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testServerAsync() throws Exception { Service service=Service.create(serviceName); service.addPort(fakePortName,javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING,"http://localhost:" + PORT + "/SoapContext/AsyncSoapPort"); Greeter greeter=service.getPort(fakePortName,Greeter.class); String resp=greeter.greetMe("World"); assertEquals("Hello World",resp); }

InternalCallVerifier IdentityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAsyncCallUseProperAssignedExecutor() throws Exception { URL wsdl=getClass().getResource("/wsdl/hello_world.wsdl"); assertNotNull(wsdl); SOAPService service=new SOAPService(wsdl,serviceName); class TestExecutor implements Executor { private AtomicInteger count=new AtomicInteger(); public void execute( Runnable command){ int c=count.incrementAndGet(); LOG.info("asyn call time " + c); command.run(); } public int getCount(){ return count.get(); } } Executor executor=new TestExecutor(); service.setExecutor(executor); assertNotNull(service); assertSame(executor,service.getExecutor()); assertEquals(((TestExecutor)executor).getCount(),0); Greeter greeter=service.getPort(portName,Greeter.class); updateAddressPort(greeter,PORT); List> responses=new ArrayList>(); for (int i=0; i < 5; i++) { responses.add(greeter.greetMeAsync("asyn call" + i)); } for ( Response resp : responses) { resp.get(); } assertEquals(5,((TestExecutor)executor).getCount()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetPortOneParam() throws Exception { URL url=getClass().getResource("/wsdl/hello_world.wsdl"); Service service=Service.create(url,serviceName); Greeter greeter=service.getPort(Greeter.class); String response=new String("Bonjour"); try { ((BindingProvider)greeter).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,"http://localhost:" + PORT + "/SoapContext/SoapPort"); greeter.greetMe("test"); String reply=greeter.sayHi(); assertNotNull("no response received from service",reply); assertEquals(response,reply); } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

APIUtilityVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAsyncSynchronousPolling() throws Exception { URL wsdl=getClass().getResource("/wsdl/hello_world.wsdl"); assertNotNull(wsdl); SOAPService service=new SOAPService(wsdl,serviceName); assertNotNull(service); final String expectedString=new String("Hello, finally!"); class Poller extends Thread { Response response; int tid; Poller( Response r, int t){ response=r; tid=t; } public void run(){ if (tid % 2 > 0) { while (!response.isDone()) { try { Thread.sleep(100); } catch ( InterruptedException ex) { } } } GreetMeLaterResponse reply=null; try { reply=response.get(); } catch ( Exception ex) { fail("Poller " + tid + " failed with "+ ex); } assertNotNull("Poller " + tid + ": no response received from service",reply); String s=reply.getResponseType(); assertEquals(expectedString,s); } } Greeter greeter=service.getPort(portName,Greeter.class); updateAddressPort(greeter,PORT); long before=System.currentTimeMillis(); long delay=3000; Response response=greeter.greetMeLaterAsync(delay); long after=System.currentTimeMillis(); assertTrue("Duration of calls exceeded " + delay + " ms",after - before < delay); assertFalse("Response already available.",response.isDone()); Poller[] pollers=new Poller[4]; for (int i=0; i < pollers.length; i++) { pollers[i]=new Poller(response,i); } for ( Poller p : pollers) { p.start(); } for ( Poller p : pollers) { p.join(); } }

UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBogusAddress() throws Exception { String realAddress="http://localhost:" + BOGUS_REAL_PORT + "/SoapContext/SoapPort"; SOAPServiceBogusAddressTest service=new SOAPServiceBogusAddressTest(); Greeter greeter=service.getSoapPort(); try { greeter.greetMe("test"); fail("Should fail"); } catch ( WebServiceException f) { } BindingProvider bp=(BindingProvider)greeter; bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,realAddress); greeter.greetMe("test"); greeter.greetMe("test"); bp.getRequestContext().remove(BindingProvider.ENDPOINT_ADDRESS_PROPERTY); try { greeter.greetMe("test"); fail("Should fail"); } catch ( WebServiceException f) { } bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,realAddress); String reply=greeter.sayHi(); assertNotNull("no response received from service",reply); assertEquals("Bonjour",reply); }

IterativeVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBasicConnectionAndOneway() throws Exception { URL wsdl=getClass().getResource("/wsdl/hello_world.wsdl"); assertNotNull(wsdl); SOAPService service=new SOAPService(wsdl,serviceName); assertNotNull(service); Greeter greeter=service.getPort(portName,Greeter.class); updateAddressPort(greeter,PORT); String response1=new String("Hello Milestone-"); String response2=new String("Bonjour"); try { for (int idx=0; idx < 1; idx++) { String greeting=greeter.greetMe("Milestone-" + idx); assertNotNull("no response received from service",greeting); String exResponse=response1 + idx; assertEquals(exResponse,greeting); String reply=greeter.sayHi(); assertNotNull("no response received from service",reply); assertEquals(response2,reply); greeter.greetMeOneWay("Milestone-" + idx); } } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBasicConnection() throws Exception { SOAPService service=new SOAPService(); assertNotNull(service); Greeter greeter=service.getPort(portName,Greeter.class); updateAddressPort(greeter,PORT); try { greeter.greetMe("test"); String reply=greeter.sayHi(); assertNotNull("no response received from service",reply); assertEquals("Bonjour",reply); } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } BindingProvider bp=(BindingProvider)greeter; Map responseContext=bp.getResponseContext(); Integer responseCode=(Integer)responseContext.get(Message.RESPONSE_CODE); assertEquals(200,responseCode.intValue()); }

APIUtilityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetWSDL() throws Exception { String url="http://localhost:" + PORT + "/SoapContext/SoapPort?wsdl"; HttpURLConnection httpConnection=getHttpConnection(url); httpConnection.setRequestProperty("Accept-Encoding","gzip, deflate"); httpConnection.connect(); assertEquals(200,httpConnection.getResponseCode()); assertEquals("text/xml;charset=utf-8",stripSpaces(httpConnection.getContentType().toLowerCase())); assertEquals("OK",httpConnection.getResponseMessage()); InputStream in=httpConnection.getInputStream(); assertNotNull(in); Document doc=StaxUtils.read(in); assertNotNull(doc); }

APIUtilityVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAsyncCallWithHandlerAndMultipleClients() throws Exception { URL wsdl=getClass().getResource("/wsdl/hello_world.wsdl"); assertNotNull(wsdl); SOAPService service=new SOAPService(wsdl,serviceName); assertNotNull(service); final MyHandler h=new MyHandler(); MyHandler.invocationCount=0; final String expectedString=new String("Hello, finally!"); class Poller extends Thread { Future future; int tid; Poller( Future f, int t){ future=f; tid=t; } public void run(){ if (tid % 2 > 0) { while (!future.isDone()) { try { Thread.sleep(100); } catch ( InterruptedException ex) { ex.printStackTrace(); } } } try { future.get(); } catch ( Exception ex) { fail("Poller " + tid + " failed with "+ ex); } assertEquals("callback was not executed or did not return the expected result",expectedString,h.getReplyBuffer()); } } Greeter greeter=service.getPort(portName,Greeter.class); updateAddressPort(greeter,PORT); long before=System.currentTimeMillis(); long delay=3000; Future f=greeter.greetMeLaterAsync(delay,h); long after=System.currentTimeMillis(); assertTrue("Duration of calls exceeded " + delay + " ms",after - before < delay); assertFalse("Response already available.",f.isDone()); Poller[] pollers=new Poller[4]; for (int i=0; i < pollers.length; i++) { pollers[i]=new Poller(f,i); } for ( Poller p : pollers) { p.start(); } for ( Poller p : pollers) { p.join(); } assertEquals(1,MyHandler.invocationCount); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAsyncCallWithHandler() throws Exception { URL wsdl=getClass().getResource("/wsdl/hello_world.wsdl"); assertNotNull(wsdl); SOAPService service=new SOAPService(wsdl,serviceName); assertNotNull(service); MyHandler h=new MyHandler(); MyHandler.invocationCount=0; String expectedString=new String("Hello, finally!"); try { Greeter greeter=service.getPort(portName,Greeter.class); updateAddressPort(greeter,PORT); long before=System.currentTimeMillis(); long delay=3000; Future f=greeter.greetMeLaterAsync(delay,h); long after=System.currentTimeMillis(); assertTrue("Duration of calls exceeded " + delay + " ms",after - before < delay); assertFalse("Response already available.",f.isDone()); int i=0; while (!f.isDone() && i < 50) { Thread.sleep(100); i++; } assertEquals("callback was not executed or did not return the expected result",expectedString,h.getReplyBuffer()); } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } assertEquals(1,MyHandler.invocationCount); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAddPort() throws Exception { Service service=Service.create(serviceName); service.addPort(fakePortName,"http://schemas.xmlsoap.org/soap/","http://localhost:" + PORT + "/SoapContext/SoapPort"); Greeter greeter=service.getPort(fakePortName,Greeter.class); String response=new String("Bonjour"); try { greeter.greetMe("test"); String reply=greeter.sayHi(); assertNotNull("no response received from service",reply); assertEquals(response,reply); } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

APIUtilityVerifier EqualityVerifier 
@Test public void testEchoProviderAsync() throws Exception { String requestString=""; Service service=Service.create(serviceName); service.addPort(fakePortName,javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING,"http://localhost:" + PORT + "/SoapContext/AsyncEchoProvider"); Dispatch dispatcher=service.createDispatch(fakePortName,StreamSource.class,Service.Mode.PAYLOAD); StreamSource request=new StreamSource(new ByteArrayInputStream(requestString.getBytes())); StreamSource response=dispatcher.invoke(request); assertEquals(requestString,StaxUtils.toString(response)); }

APIUtilityVerifier IterativeVerifier UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testFaults() throws Exception { URL wsdl=getClass().getResource("/wsdl/hello_world.wsdl"); assertNotNull(wsdl); SOAPService service=new SOAPService(wsdl,serviceName); ExecutorService ex=Executors.newFixedThreadPool(1); service.setExecutor(ex); assertNotNull(service); String noSuchCodeFault="NoSuchCodeLitFault"; String badRecordFault="BadRecordLitFault"; Greeter greeter=service.getPort(portName,Greeter.class); updateAddressPort(greeter,PORT); for (int idx=0; idx < 2; idx++) { try { greeter.testDocLitFault(noSuchCodeFault); fail("Should have thrown NoSuchCodeLitFault exception"); } catch ( NoSuchCodeLitFault nslf) { assertNotNull(nslf.getFaultInfo()); assertNotNull(nslf.getFaultInfo().getCode()); } try { greeter.testDocLitFault(badRecordFault); fail("Should have thrown BadRecordLitFault exception"); } catch ( BadRecordLitFault brlf) { BindingProvider bp=(BindingProvider)greeter; Map responseContext=bp.getResponseContext(); String contentType=(String)responseContext.get(Message.CONTENT_TYPE); assertEquals("text/xml;charset=utf-8",stripSpaces(contentType.toLowerCase())); Integer responseCode=(Integer)responseContext.get(Message.RESPONSE_CODE); assertEquals(500,responseCode.intValue()); assertNotNull(brlf.getFaultInfo()); assertEquals("BadRecordLitFault",brlf.getFaultInfo()); } } }

IterativeVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBasicConnection2() throws Exception { URL wsdl=getClass().getResource("/wsdl/hello_world.wsdl"); assertNotNull(wsdl); SOAPService service=new SOAPService(wsdl,serviceName); assertNotNull(service); Greeter greeter=service.getPort(Greeter.class); ((BindingProvider)greeter).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,"http://localhost:" + PORT + "/SoapContext/SoapPort"); String response1=new String("Hello Milestone-"); String response2=new String("Bonjour"); try { for (int idx=0; idx < 5; idx++) { String greeting=greeter.greetMe("Milestone-" + idx); assertNotNull("no response received from service",greeting); String exResponse=response1 + idx; assertEquals(exResponse,greeting); String reply=greeter.sayHi(); assertNotNull("no response received from service",reply); assertEquals(response2,reply); greeter.greetMeOneWay("Milestone-" + idx); } } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

Class: org.apache.cxf.systest.jaxws.ClientServerXMLTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAddPort() throws Exception { URL url=getClass().getResource("/wsdl/hello_world_xml_wrapped.wsdl"); Service service=Service.create(url,wrapServiceName); assertNotNull(service); service.addPort(wrapFakePortName,"http://cxf.apache.org/bindings/xformat","http://localhost:" + WRAP_PORT + "/XMLService/XMLPort"); String response1=new String("Hello "); String response2=new String("Bonjour"); org.apache.hello_world_xml_http.wrapped.Greeter greeter=service.getPort(wrapPortName,org.apache.hello_world_xml_http.wrapped.Greeter.class); updateAddressPort(greeter,WRAP_PORT); try { String username=System.getProperty("user.name"); String reply=greeter.greetMe(username); assertNotNull("no response received from service",reply); assertEquals(response1 + username,reply); reply=greeter.sayHi(); assertNotNull("no response received from service",reply); assertEquals(response2,reply); BindingProvider bp=(BindingProvider)greeter; Map responseContext=bp.getResponseContext(); Integer responseCode=(Integer)responseContext.get(Message.RESPONSE_CODE); assertEquals(200,responseCode.intValue()); greeter.greetMeOneWay(System.getProperty("user.name")); } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testWrapBasicConnection() throws Exception { org.apache.hello_world_xml_http.wrapped.XMLService service=new org.apache.hello_world_xml_http.wrapped.XMLService(this.getClass().getResource("/wsdl/hello_world_xml_wrapped.wsdl"),wrapServiceName); assertNotNull(service); String response1=new String("Hello "); String response2=new String("Bonjour"); try { org.apache.hello_world_xml_http.wrapped.Greeter greeter=service.getPort(wrapPortName,org.apache.hello_world_xml_http.wrapped.Greeter.class); updateAddressPort(greeter,WRAP_PORT); String username=System.getProperty("user.name"); String reply=greeter.greetMe(username); assertNotNull("no response received from service",reply); assertEquals(response1 + username,reply); reply=greeter.sayHi(); assertNotNull("no response received from service",reply); assertEquals(response2,reply); greeter.greetMeOneWay(System.getProperty("user.name")); } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

APIUtilityVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testXMLFault() throws Exception { org.apache.hello_world_xml_http.wrapped.XMLService service=new org.apache.hello_world_xml_http.wrapped.XMLService(this.getClass().getResource("/wsdl/hello_world_xml_wrapped.wsdl"),wrapServiceName); assertNotNull(service); org.apache.hello_world_xml_http.wrapped.Greeter greeter=service.getPort(wrapPortName,org.apache.hello_world_xml_http.wrapped.Greeter.class); updateAddressPort(greeter,WRAP_PORT); try { greeter.pingMe(); fail("did not catch expected PingMeFault exception"); } catch ( PingMeFault ex) { assertEquals("minor value",1,ex.getFaultInfo().getMinor()); assertEquals("major value",2,ex.getFaultInfo().getMajor()); BindingProvider bp=(BindingProvider)greeter; Map responseContext=bp.getResponseContext(); String contentType=(String)responseContext.get(Message.CONTENT_TYPE); assertEquals("text/xml;charset=utf-8",stripSpaces(contentType.toLowerCase())); Integer responseCode=(Integer)responseContext.get(Message.RESPONSE_CODE); assertEquals(500,responseCode.intValue()); } org.apache.hello_world_xml_http.wrapped.Greeter greeterFault=service.getXMLFaultPort(); updateAddressPort(greeterFault,REG_PORT); try { greeterFault.pingMe(); fail("did not catch expected runtime exception"); } catch ( HTTPException ex) { assertTrue("check expected message of exception",ex.getCause().getMessage().indexOf(GreeterFaultImpl.RUNTIME_EXCEPTION_MESSAGE) >= 0); } }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testMixedConnection() throws Exception { org.apache.hello_world_xml_http.mixed.XMLService service=new org.apache.hello_world_xml_http.mixed.XMLService(this.getClass().getResource("/wsdl/hello_world_xml_mixed.wsdl"),mixedServiceName); assertNotNull(service); String response1=new String("Hello "); String response2=new String("Bonjour"); try { org.apache.hello_world_xml_http.mixed.Greeter greeter=service.getPort(mixedPortName,org.apache.hello_world_xml_http.mixed.Greeter.class); updateAddressPort(greeter,MIX_PORT); String username=System.getProperty("user.name"); String reply=greeter.greetMe(username); assertNotNull("no response received from service",reply); assertEquals(response1 + username,reply); SayHi request=new SayHi(); SayHiResponse response=greeter.sayHi1(request); assertNotNull("no response received from service",response); assertEquals(response2,response.getResponseType()); greeter.greetMeOneWay(System.getProperty("user.name")); } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBareBasicConnection() throws Exception { XMLService service=new XMLService(); assertNotNull(service); String response1="Hello "; String response2="Bonjour"; try { Greeter greeter=service.getPort(barePortName,Greeter.class); updateAddressPort(greeter,REG_PORT); String username=System.getProperty("user.name"); String reply=greeter.greetMe(username); assertNotNull("no response received from service",reply); assertEquals(response1 + username,reply); reply=greeter.sayHi(); assertNotNull("no response received from service",reply); assertEquals(response2,reply); MyComplexStructType argument=new MyComplexStructType(); MyComplexStructType retVal=null; String str1="this is element 1"; String str2="this is element 2"; int int1=42; argument.setElem1(str1); argument.setElem2(str2); argument.setElem3(int1); retVal=greeter.sendReceiveData(argument); assertEquals(str1,retVal.getElem1()); assertEquals(str2,retVal.getElem2()); assertEquals(int1,retVal.getElem3()); } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

Class: org.apache.cxf.systest.jaxws.JaxWsClientThreadTest

APIUtilityVerifier IterativeVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testRequestContextThreadSafetyDispatch() throws Throwable { URL url=getClass().getResource("/wsdl/hello_world.wsdl"); javax.xml.ws.Service s=javax.xml.ws.Service.create(url,serviceName); JAXBContext c=JAXBContext.newInstance(org.apache.hello_world_soap_http.types.ObjectFactory.class); final Dispatch disp=s.createDispatch(portName,c,Service.Mode.PAYLOAD); disp.getRequestContext().put(JaxWsClientProxy.THREAD_LOCAL_REQUEST_CONTEXT,Boolean.TRUE); Map requestContext=disp.getRequestContext(); String address=(String)requestContext.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY); final Throwable errorHolder[]=new Throwable[1]; Runnable r=new Runnable(){ public void run(){ try { final String protocol="http-" + Thread.currentThread().getId(); for (int i=0; i < 10; i++) { String threadSpecificaddress=protocol + "://localhost:80/" + i; Map requestContext=disp.getRequestContext(); requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,threadSpecificaddress); assertEquals("we get what we set",threadSpecificaddress,requestContext.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY)); try { org.apache.hello_world_soap_http.types.GreetMe gm=new org.apache.hello_world_soap_http.types.GreetMe(); gm.setRequestType("Hi"); disp.invoke(gm); } catch ( WebServiceException expected) { MalformedURLException mue=(MalformedURLException)expected.getCause(); if (mue == null || mue.getMessage() == null) { throw expected; } assertTrue("protocol contains thread id from context",mue.getMessage().indexOf(protocol) != 0); } requestContext.remove(BindingProvider.ENDPOINT_ADDRESS_PROPERTY); assertTrue("property is null",requestContext.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY) == null); } } catch ( Throwable t) { errorHolder[0]=t; } } } ; final int numThreads=5; Thread[] threads=new Thread[numThreads]; for (int i=0; i < numThreads; i++) { threads[i]=new Thread(r); } for (int i=0; i < numThreads; i++) { threads[i].start(); } for (int i=0; i < numThreads; i++) { threads[i].join(); } if (errorHolder[0] != null) { throw errorHolder[0]; } assertTrue("address from existing context has not changed",address.equals(requestContext.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY))); ((ClientImpl.EchoContext)((WrappedMessageContext)requestContext).getWrappedMap()).reload(); assertTrue("address is different",!address.equals(requestContext.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY))); assertTrue("property is null from last thread execution",requestContext.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY) == null); }

APIUtilityVerifier IterativeVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testRequestContextThreadSafety() throws Throwable { URL url=getClass().getResource("/wsdl/hello_world.wsdl"); javax.xml.ws.Service s=javax.xml.ws.Service.create(url,serviceName); final Greeter greeter=s.getPort(portName,Greeter.class); final InvocationHandler handler=Proxy.getInvocationHandler(greeter); ((BindingProvider)handler).getRequestContext().put(JaxWsClientProxy.THREAD_LOCAL_REQUEST_CONTEXT,Boolean.TRUE); Map requestContext=((BindingProvider)handler).getRequestContext(); String address=(String)requestContext.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY); final Throwable errorHolder[]=new Throwable[1]; Runnable r=new Runnable(){ public void run(){ try { final String protocol="http-" + Thread.currentThread().getId(); for (int i=0; i < 10; i++) { String threadSpecificaddress=protocol + "://localhost:80/" + i; Map requestContext=((BindingProvider)handler).getRequestContext(); requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,threadSpecificaddress); assertEquals("we get what we set",threadSpecificaddress,requestContext.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY)); try { greeter.greetMe("Hi"); } catch ( WebServiceException expected) { MalformedURLException mue=(MalformedURLException)expected.getCause(); if (mue == null || mue.getMessage() == null) { throw expected; } assertTrue("protocol contains thread id from context",mue.getMessage().indexOf(protocol) != 0); } requestContext.remove(BindingProvider.ENDPOINT_ADDRESS_PROPERTY); assertTrue("property is null",requestContext.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY) == null); } } catch ( Throwable t) { errorHolder[0]=t; } } } ; final int numThreads=5; Thread[] threads=new Thread[numThreads]; for (int i=0; i < numThreads; i++) { threads[i]=new Thread(r); } for (int i=0; i < numThreads; i++) { threads[i].start(); } for (int i=0; i < numThreads; i++) { threads[i].join(); } if (errorHolder[0] != null) { throw errorHolder[0]; } assertTrue("address from existing context has not changed",address.equals(requestContext.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY))); ((ClientImpl.EchoContext)((WrappedMessageContext)requestContext).getWrappedMap()).reload(); assertTrue("address is different",!address.equals(requestContext.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY))); assertTrue("property is null from last thread execution",requestContext.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY) == null); }

Class: org.apache.cxf.systest.jaxws.JaxWsDynamicClientTest

InternalCallVerifier EqualityVerifier 
@Test public void testInvocation() throws Exception { JaxWsDynamicClientFactory dcf=JaxWsDynamicClientFactory.newInstance(); URL wsdlURL=new URL("http://localhost:" + PORT + "/NoBodyParts/NoBodyPartsService?wsdl"); Client client=dcf.createClient(wsdlURL); byte[] bucketOfBytes=IOUtils.readBytesFromStream(getClass().getResourceAsStream("/wsdl/no_body_parts.wsdl")); Operation1 parameters=new Operation1(); parameters.setOptionString("opt-ion"); parameters.setTargetType("tar-get"); Object[] rparts=client.invoke("operation1",parameters,bucketOfBytes); Operation1Response r=(Operation1Response)rparts[0]; assertEquals(md5(bucketOfBytes),r.getStatus()); ClientCallback callback=new ClientCallback(); client.invoke(callback,"operation1",parameters,bucketOfBytes); rparts=callback.get(); r=(Operation1Response)rparts[0]; assertEquals(md5(bucketOfBytes),r.getStatus()); }

Class: org.apache.cxf.systest.jaxws.JaxwsExecutorTest

BooleanVerifier InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testUseCustomExecutorOnClient() throws Exception { BasicGreeterService service=new BasicGreeterService(); class CustomExecutor implements Executor { private int count; public void execute( Runnable command){ count++; command.run(); } public int getCount(){ return count; } } CustomExecutor executor=new CustomExecutor(); service.setExecutor(executor); assertSame(executor,service.getExecutor()); Greeter proxy=service.getGreeterPort(); updateAddressPort(proxy,PORT); assertEquals(0,executor.getCount()); Response response=proxy.greetMeAsync("cxf"); int waitCount=0; while (!response.isDone() && waitCount < 15) { Thread.sleep(1000); waitCount++; } assertTrue("Response still not received.",response.isDone()); assertEquals(1,executor.getCount()); }

Class: org.apache.cxf.systest.jaxws.SchemaValidationClientServerTest

BranchVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSchemaValidationWithMultipleXsds() throws Exception { Service service=new Service(); assertNotNull(service); try (ServicePortType greeter=service.getPort(portName,ServicePortType.class)){ greeter.getInInterceptors().add(new LoggingInInterceptor()); greeter.getOutInterceptors().add(new LoggingOutInterceptor()); updateAddressPort(greeter,PORT); RequestIdType requestId=new RequestIdType(); requestId.setId("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); CkRequestType request=new CkRequestType(); request.setRequest(requestId); greeter.getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED,Boolean.TRUE); RequestHeader header=new RequestHeader(); header.setHeaderValue("AABBCC"); CkResponseType response=greeter.ckR(request,header); assertEquals(response.getProduct().get(0).getAction().getStatus(),4); try { requestId.setId("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeeez"); request.setRequest(requestId); greeter.ckR(request,header); fail("should catch marshall exception as the invalid outgoing message per schema"); } catch ( Exception e) { assertTrue(e.getMessage().contains("Marshalling Error")); boolean english="en".equals(java.util.Locale.getDefault().getLanguage()); if (english) { assertTrue(e.getMessage().contains("is not facet-valid with respect to pattern")); } } try { requestId.setId("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); request.setRequest(requestId); header.setHeaderValue("AABBCCDDEEFFGGHHIIJJ"); greeter.ckR(request,header); fail("should catch marshall exception as the invalid outgoing message per schema"); } catch ( Exception e) { assertTrue(e.getMessage().contains("Marshalling Error")); boolean english="en".equals(java.util.Locale.getDefault().getLanguage()); if (english) { assertTrue(e.getMessage().contains("is not facet-valid with respect to maxLength")); } } try { requestId.setId("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); request.setRequest(requestId); header.setHeaderValue("AABBCCDDEEFFGGHHIIJJ"); greeter.getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED,Boolean.FALSE); greeter.ckR(request,header); fail("should catch marshall exception as the invalid outgoing message per schema"); } catch ( Exception e) { assertTrue(e.getMessage().contains("Could not validate soapheader ")); boolean english="en".equals(java.util.Locale.getDefault().getLanguage()); if (english) { assertTrue(e.getMessage().contains("is not facet-valid with respect to maxLength")); } } } }

Class: org.apache.cxf.systest.jaxws.beanpostprocessor.BeanPostProcessorTest

InternalCallVerifier EqualityVerifier 
@Test public void verifyServices() throws Exception { JaxWsClientFactoryBean cf=new JaxWsClientFactoryBean(); cf.setAddress("local://services/Alger"); cf.setServiceClass(IWebServiceRUs.class); Client client=cf.create(); String response=(String)client.invoke("consultTheOracle")[0]; assertEquals("All your bases belong to us.",response); Service service=WebServiceRUs.getService(); assertEquals(JAXBDataBinding.class,service.getDataBinding().getClass()); }

Class: org.apache.cxf.systest.jaxws.websocket.ClientServerWebSocketTest

APIUtilityVerifier IterativeVerifier UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testFaults() throws Exception { URL wsdl=getClass().getResource("/wsdl/hello_world.wsdl"); assertNotNull(wsdl); SOAPService service=new SOAPService(wsdl,serviceName); ExecutorService ex=Executors.newFixedThreadPool(1); service.setExecutor(ex); assertNotNull(service); String noSuchCodeFault="NoSuchCodeLitFault"; String badRecordFault="BadRecordLitFault"; Greeter greeter=service.getPort(portName,Greeter.class); updateGreeterAddress(greeter,PORT); for (int idx=0; idx < 2; idx++) { try { greeter.testDocLitFault(noSuchCodeFault); fail("Should have thrown NoSuchCodeLitFault exception"); } catch ( NoSuchCodeLitFault nslf) { assertNotNull(nslf.getFaultInfo()); assertNotNull(nslf.getFaultInfo().getCode()); } try { greeter.testDocLitFault(badRecordFault); fail("Should have thrown BadRecordLitFault exception"); } catch ( BadRecordLitFault brlf) { BindingProvider bp=(BindingProvider)greeter; Map responseContext=bp.getResponseContext(); String contentType=(String)responseContext.get(Message.CONTENT_TYPE); assertEquals("text/xml; charset=utf-8",contentType.toLowerCase()); Integer responseCode=(Integer)responseContext.get(Message.RESPONSE_CODE); assertEquals(500,responseCode.intValue()); assertNotNull(brlf.getFaultInfo()); assertEquals("BadRecordLitFault",brlf.getFaultInfo()); } } }

IterativeVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBasicConnectionAndOneway() throws Exception { URL wsdl=getClass().getResource("/wsdl/hello_world.wsdl"); assertNotNull(wsdl); SOAPService service=new SOAPService(wsdl,serviceName); Greeter greeter=service.getPort(portName,Greeter.class); updateGreeterAddress(greeter,PORT); String response1=new String("Hello Milestone-"); String response2=new String("Bonjour"); try { for (int idx=0; idx < 1; idx++) { String greeting=greeter.greetMe("Milestone-" + idx); assertNotNull("no response received from service",greeting); String exResponse=response1 + idx; assertEquals(exResponse,greeting); String reply=greeter.sayHi(); assertNotNull("no response received from service",reply); assertEquals(response2,reply); greeter.greetMeOneWay("Milestone-" + idx); } } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

IterativeVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBasicConnection2() throws Exception { URL wsdl=getClass().getResource("/wsdl/hello_world.wsdl"); assertNotNull(wsdl); SOAPService service=new SOAPService(wsdl,serviceName); Greeter greeter=service.getPort(Greeter.class); updateGreeterAddress(greeter,PORT); String response1=new String("Hello Milestone-"); String response2=new String("Bonjour"); try { for (int idx=0; idx < 5; idx++) { String greeting=greeter.greetMe("Milestone-" + idx); assertNotNull("no response received from service",greeting); String exResponse=response1 + idx; assertEquals(exResponse,greeting); String reply=greeter.sayHi(); assertNotNull("no response received from service",reply); assertEquals(response2,reply); greeter.greetMeOneWay("Milestone-" + idx); } } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

APIUtilityVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAsyncSynchronousPolling() throws Exception { URL wsdl=getClass().getResource("/wsdl/hello_world.wsdl"); assertNotNull(wsdl); SOAPService service=new SOAPService(wsdl,serviceName); assertNotNull(service); final String expectedString=new String("Hello, finally!"); class Poller extends Thread { Response response; int tid; Poller( Response r, int t){ response=r; tid=t; } public void run(){ if (tid % 2 > 0) { while (!response.isDone()) { try { Thread.sleep(100); } catch ( InterruptedException ex) { } } } GreetMeLaterResponse reply=null; try { reply=response.get(); } catch ( Exception ex) { fail("Poller " + tid + " failed with "+ ex); } assertNotNull("Poller " + tid + ": no response received from service",reply); String s=reply.getResponseType(); assertEquals(expectedString,s); } } Greeter greeter=service.getPort(portName,Greeter.class); updateGreeterAddress(greeter,PORT); long before=System.currentTimeMillis(); long delay=3000; Response response=greeter.greetMeLaterAsync(delay); long after=System.currentTimeMillis(); assertTrue("Duration of calls exceeded " + delay + " ms",after - before < delay); assertFalse("Response already available.",response.isDone()); Poller[] pollers=new Poller[4]; for (int i=0; i < pollers.length; i++) { pollers[i]=new Poller(response,i); } for ( Poller p : pollers) { p.start(); } for ( Poller p : pollers) { p.join(); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBasicConnection() throws Exception { SOAPService service=new SOAPService(); Greeter greeter=service.getPort(portName,Greeter.class); updateGreeterAddress(greeter,PORT); try { String reply=greeter.greetMe("test"); assertNotNull("no response received from service",reply); assertEquals("Hello test",reply); reply=greeter.sayHi(); assertNotNull("no response received from service",reply); assertEquals("Bonjour",reply); } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } BindingProvider bp=(BindingProvider)greeter; Map responseContext=bp.getResponseContext(); Integer responseCode=(Integer)responseContext.get(Message.RESPONSE_CODE); assertEquals(200,responseCode.intValue()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test @org.junit.Ignore public void testBasicAuth() throws Exception { URL wsdl=getClass().getResource("/wsdl/hello_world.wsdl"); assertNotNull(wsdl); SOAPService service=new SOAPService(wsdl,serviceName); Greeter greeter=service.getPort(portName,Greeter.class); updateGreeterAddress(greeter,PORT); try { BindingProvider bp=(BindingProvider)greeter; bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY,"BJ"); bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY,"pswd"); String s=greeter.greetMe("secure"); assertEquals("Hello BJ",s); bp.getRequestContext().remove(BindingProvider.USERNAME_PROPERTY); bp.getRequestContext().remove(BindingProvider.PASSWORD_PROPERTY); Client client=ClientProxy.getClient(greeter); HTTPConduit httpConduit=(HTTPConduit)client.getConduit(); AuthorizationPolicy policy=new AuthorizationPolicy(); policy.setUserName("BJ2"); policy.setPassword("pswd"); httpConduit.setAuthorization(policy); s=greeter.greetMe("secure"); assertEquals("Hello BJ2",s); } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

Class: org.apache.cxf.systest.jibx.ClientServerJibxTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCallFromDocLitBareClient() throws Exception { SpringBusFactory factory=new SpringBusFactory(); Bus bus=factory.createBus("org/apache/cxf/systest/jibx/cxf.xml"); BusFactory.setDefaultBus(bus); URL wsdl=this.getClass().getResource("/wsdl_systest_databinding/jibx/doc_lit_bare.wsdl"); assertNotNull("We should have found the WSDL here. ",wsdl); org.apache.cxf.jibx.doc_lit_bare.SOAPService ss=new org.apache.cxf.jibx.doc_lit_bare.SOAPService(wsdl,DOC_LIT_BARE_SERVICE); PutLastTradedPricePortType port=ss.getSoapPort(); updateAddressPort(port,WSDL_PORT); ClientProxy.getClient(port).getInInterceptors().add(new LoggingInInterceptor()); ClientProxy.getClient(port).getOutInterceptors().add(new LoggingOutInterceptor()); StringRespType resp=port.bareNoParam(); assertEquals("Get a wrong response","Get the request!",resp.getStringRespType()); InDecimal xd=new InDecimal(); xd.setInDecimal(new BigDecimal(123)); OutString response=port.nillableParameter(xd); assertEquals("Get a wrong response","Get the request 123",response.getOutString()); In data=new In(); data.setTickerPrice(12.33F); data.setTickerSymbol("CXF"); port.putLastTradedPrice(data); Inout dataio=new Inout(); dataio.setTickerPrice(12.33F); dataio.setTickerSymbol("CXF"); Holder holder=new Holder(dataio); port.sayHi(holder); assertEquals("Get a wrong response","BAK",holder.value.getTickerSymbol()); }

UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCallFromClient() throws Exception { SpringBusFactory factory=new SpringBusFactory(); Bus bus=factory.createBus("org/apache/cxf/systest/jibx/cxf.xml"); BusFactory.setDefaultBus(bus); URL wsdl=this.getClass().getResource("/wsdl_systest_databinding/jibx/hello_world.wsdl"); assertNotNull("We should have found the WSDL here. ",wsdl); SOAPService ss=new SOAPService(wsdl,SERVICE_NAME); Greeter port=ss.getSoapPort(); updateAddressPort(port,WSDL_PORT); String resp; ClientProxy.getClient(port).getInInterceptors().add(new LoggingInInterceptor()); ClientProxy.getClient(port).getOutInterceptors().add(new LoggingOutInterceptor()); resp=port.sayHi(); assertEquals("We should get the right response","Bonjour",resp); resp=port.greetMe("Willem"); assertEquals("We should get the right response","Hello Willem",resp); try { port.greetMe("fault"); fail("Should have been a fault"); } catch ( GreetMeFault ex) { assertEquals("Some fault detail",ex.getFaultInfo().getGreetMeFaultDetail()); } try { port.pingMe(); fail("We expect exception here"); } catch ( PingMeFault ex) { FaultDetail detail=ex.getFaultInfo(); assertEquals("Wrong faultDetail major",detail.getMajor(),2); assertEquals("Wrong faultDetail minor",detail.getMinor(),1); } }

Class: org.apache.cxf.systest.jms.JMSClientServerSoap12Test

IterativeVerifier UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGzipEncodingWithJms() throws Exception { QName serviceName=new QName("http://apache.org/hello_world_doc_lit","SOAPService8"); QName portName=new QName("http://apache.org/hello_world_doc_lit","SoapPort8"); URL wsdl=getWSDLURL("/wsdl/hello_world_doc_lit.wsdl"); SOAPService2 service=new SOAPService2(wsdl,serviceName); Greeter greeter=markForClose(service.getPort(portName,Greeter.class,cff)); for (int idx=0; idx < 5; idx++) { greeter.greetMeOneWay("test String"); String greeting=greeter.greetMe("Milestone-" + idx); Assert.assertEquals(new String("Hello Milestone-") + idx,greeting); String reply=greeter.sayHi(); Assert.assertEquals("Bonjour",reply); try { greeter.pingMe(); Assert.fail("Should have thrown FaultException"); } catch ( PingMeFault ex) { Assert.assertNotNull(ex.getFaultInfo()); } } }

IterativeVerifier UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testWSAddressingWithJms() throws Exception { QName serviceName=new QName("http://apache.org/hello_world_doc_lit","SOAPService8"); QName portName=new QName("http://apache.org/hello_world_doc_lit","SoapPort8"); URL wsdl=getWSDLURL("/wsdl/hello_world_doc_lit.wsdl"); SOAPService2 service=new SOAPService2(wsdl,serviceName); Greeter greeter=markForClose(service.getPort(portName,Greeter.class,cff,new AddressingFeature())); for (int idx=0; idx < 5; idx++) { greeter.greetMeOneWay("test String"); String greeting=greeter.greetMe("Milestone-" + idx); Assert.assertEquals(new String("Hello Milestone-") + idx,greeting); String reply=greeter.sayHi(); Assert.assertEquals("Bonjour",reply); try { greeter.pingMe(); Assert.fail("Should have thrown FaultException"); } catch ( PingMeFault ex) { Assert.assertNotNull(ex.getFaultInfo()); } } }

Class: org.apache.cxf.systest.jms.JMSClientServerTest

InternalCallVerifier EqualityVerifier 
@Test public void testReplyToConfig() throws Exception { ActiveMQConnectionFactory cf=new ActiveMQConnectionFactory(broker.getBrokerURL()); TestReceiver receiver=new TestReceiver(cf,"SoapService7.replyto.queue",false); receiver.setStaticReplyQueue("SoapService7.reply.queue"); receiver.runAsync(); QName serviceName=new QName("http://apache.org/hello_world_doc_lit","SOAPService7"); QName portName=new QName("http://apache.org/hello_world_doc_lit","SoapPort7"); URL wsdl=getWSDLURL("/wsdl/hello_world_doc_lit.wsdl"); SOAPService7 service=new SOAPService7(wsdl,serviceName); Greeter greeter=service.getPort(portName,Greeter.class); String name="FooBar"; String reply=greeter.greetMe(name); Assert.assertEquals("Hello " + name,reply); ((Closeable)greeter).close(); }

IterativeVerifier UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void docBasicJmsDestinationTest() throws Exception { QName serviceName=new QName("http://apache.org/hello_world_doc_lit","SOAPService6"); QName portName=new QName("http://apache.org/hello_world_doc_lit","SoapPort6"); URL wsdl=getWSDLURL("/wsdl/hello_world_doc_lit.wsdl"); SOAPService2 service=new SOAPService2(wsdl,serviceName); Greeter greeter=service.getPort(portName,Greeter.class); for (int idx=0; idx < 5; idx++) { greeter.greetMeOneWay("test String"); String greeting=greeter.greetMe("Milestone-" + idx); assertEquals("Hello Milestone-" + idx,greeting); String reply=greeter.sayHi(); assertEquals("Bonjour",reply); try { greeter.pingMe(); fail("Should have thrown FaultException"); } catch ( PingMeFault ex) { assertNotNull(ex.getFaultInfo()); } } ((java.io.Closeable)greeter).close(); }

BranchVerifier UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testQueueOneWaySpecCompliantConnection() throws Throwable { QName serviceName=new QName("http://cxf.apache.org/hello_world_jms","HelloWorldQueueDecoupledOneWaysService"); QName portName=new QName("http://cxf.apache.org/hello_world_jms","HelloWorldQueueDecoupledOneWaysPort"); URL wsdl=getWSDLURL("/wsdl/jms_test.wsdl"); assertNotNull(wsdl); String wsdlString2="testutils/jms_test.wsdl"; wsdlStrings.add(wsdlString2); broker.updateWsdl(getBus(),wsdlString2); HelloWorldQueueDecoupledOneWaysService service=new HelloWorldQueueDecoupledOneWaysService(wsdl,serviceName); assertNotNull(service); Endpoint requestEndpoint=null; HelloWorldOneWayPort greeter=service.getPort(portName,HelloWorldOneWayPort.class); try { GreeterImplQueueDecoupledOneWays requestServant=new GreeterImplQueueDecoupledOneWays(true); requestEndpoint=Endpoint.publish(null,requestServant); BindingProvider bp=(BindingProvider)greeter; Map requestContext=bp.getRequestContext(); JMSMessageHeadersType requestHeader=new JMSMessageHeadersType(); requestHeader.setJMSReplyTo("dynamicQueues/test.jmstransport.oneway.with.set.replyto.reply"); requestContext.put(JMSConstants.JMS_CLIENT_REQUEST_HEADERS,requestHeader); String expectedRequest="JMS:Queue:Request"; greeter.greetMeOneWay(expectedRequest); String request=requestServant.ackRequestReceived(5000); if (request == null) { if (requestServant.getException() != null) { fail(requestServant.getException().getMessage()); } else { fail("The oneway call didn't reach its intended endpoint"); } } assertEquals(expectedRequest,request); requestServant.proceedWithReply(); boolean ack=requestServant.ackNoReplySent(5000); if (!ack) { if (requestServant.getException() != null) { throw requestServant.getException(); } else { fail("The decoupled one-way reply was sent"); } } } catch ( Exception ex) { throw ex; } finally { if (requestEndpoint != null) { requestEndpoint.stop(); } ((java.io.Closeable)greeter).close(); } }

BranchVerifier UtilityVerifier InternalCallVerifier EqualityVerifier IgnoredMethod HybridVerifier 
@Test @Ignore public void testQueueDecoupledOneWaysConnection() throws Exception { QName serviceName=new QName("http://cxf.apache.org/hello_world_jms","HelloWorldQueueDecoupledOneWaysService"); QName portName=new QName("http://cxf.apache.org/hello_world_jms","HelloWorldQueueDecoupledOneWaysPort"); URL wsdl=getWSDLURL("/wsdl/jms_test.wsdl"); String wsdl2="testutils/jms_test.wsdl".intern(); wsdlStrings.add(wsdl2); broker.updateWsdl(getBus(),wsdl2); HelloWorldQueueDecoupledOneWaysService service=new HelloWorldQueueDecoupledOneWaysService(wsdl,serviceName); Endpoint requestEndpoint=null; Endpoint replyEndpoint=null; HelloWorldOneWayPort greeter=service.getPort(portName,HelloWorldOneWayPort.class); try { GreeterImplQueueDecoupledOneWays requestServant=new GreeterImplQueueDecoupledOneWays(); requestEndpoint=Endpoint.publish("",requestServant); GreeterImplQueueDecoupledOneWaysDeferredReply replyServant=new GreeterImplQueueDecoupledOneWaysDeferredReply(); replyEndpoint=Endpoint.publish("",replyServant); BindingProvider bp=(BindingProvider)greeter; Map requestContext=bp.getRequestContext(); JMSMessageHeadersType requestHeader=new JMSMessageHeadersType(); requestHeader.setJMSReplyTo("dynamicQueues/test.jmstransport.oneway.with.set.replyto.reply"); requestContext.put(JMSConstants.JMS_CLIENT_REQUEST_HEADERS,requestHeader); String expectedRequest="JMS:Queue:Request"; greeter.greetMeOneWay(expectedRequest); String request=requestServant.ackRequestReceived(5000); if (request == null) { if (requestServant.getException() != null) { fail(requestServant.getException().getMessage()); } else { fail("The oneway call didn't reach its intended endpoint"); } } assertEquals(expectedRequest,request); requestServant.proceedWithReply(); String expectedReply=requestServant.ackReplySent(5000); if (expectedReply == null) { if (requestServant.getException() != null) { fail(requestServant.getException().getMessage()); } else { fail("The decoupled one-way reply was not sent"); } } String reply=replyServant.ackRequest(5000); if (reply == null) { if (replyServant.getException() != null) { fail(replyServant.getException().getMessage()); } else { fail("The decoupled one-way reply didn't reach its intended endpoint"); } } assertEquals(expectedReply,reply); } catch ( Exception ex) { throw ex; } finally { if (requestEndpoint != null) { requestEndpoint.stop(); } if (replyEndpoint != null) { replyEndpoint.stop(); } ((java.io.Closeable)greeter).close(); } }

IterativeVerifier UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBasicConnection() throws Exception { QName serviceName=new QName("http://cxf.apache.org/hello_world_jms","HelloWorldService"); QName portName=new QName("http://cxf.apache.org/hello_world_jms","HelloWorldPort"); URL wsdl=getWSDLURL("/wsdl/jms_test.wsdl"); HelloWorldService service=new HelloWorldService(wsdl,serviceName); String response1=new String("Hello Milestone-"); String response2=new String("Bonjour"); HelloWorldPortType greeter=service.getPort(portName,HelloWorldPortType.class); for (int idx=0; idx < 5; idx++) { String greeting=greeter.greetMe("Milestone-" + idx); assertNotNull("no response received from service",greeting); String exResponse=response1 + idx; assertEquals(exResponse,greeting); String reply=greeter.sayHi(); assertNotNull("no response received from service",reply); assertEquals(response2,reply); try { greeter.testRpcLitFault("BadRecordLitFault"); fail("Should have thrown BadRecoedLitFault"); } catch ( BadRecordLitFault ex) { assertNotNull(ex.getFaultInfo()); } try { greeter.testRpcLitFault("NoSuchCodeLitFault"); fail("Should have thrown NoSuchCodeLitFault exception"); } catch ( NoSuchCodeLitFault nslf) { assertNotNull(nslf.getFaultInfo()); assertNotNull(nslf.getFaultInfo().getCode()); } } ((java.io.Closeable)greeter).close(); }

IterativeVerifier UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDocBasicConnection() throws Exception { QName serviceName=new QName("http://apache.org/hello_world_doc_lit","SOAPService2"); QName portName=new QName("http://apache.org/hello_world_doc_lit","SoapPort2"); URL wsdl=getWSDLURL("/wsdl/hello_world_doc_lit.wsdl"); SOAPService2 service=new SOAPService2(wsdl,serviceName); String response1=new String("Hello Milestone-"); String response2=new String("Bonjour"); Greeter greeter=service.getPort(portName,Greeter.class); Client client=ClientProxy.getClient(greeter); client.getEndpoint().getOutInterceptors().add(new TibcoSoapActionInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); client.getInInterceptors().add(new LoggingInInterceptor()); for (int idx=0; idx < 5; idx++) { greeter.greetMeOneWay("test String"); String greeting=greeter.greetMe("Milestone-" + idx); assertNotNull("no response received from service",greeting); String exResponse=response1 + idx; assertEquals(exResponse,greeting); String reply=greeter.sayHi(); assertNotNull("no response received from service",reply); assertEquals(response2,reply); try { greeter.pingMe(); fail("Should have thrown FaultException"); } catch ( PingMeFault ex) { assertNotNull(ex.getFaultInfo()); } } ((java.io.Closeable)greeter).close(); }

IterativeVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testByteMessage() throws Exception { QName serviceName=new QName("http://cxf.apache.org/hello_world_jms","HWByteMsgService"); URL wsdl=getWSDLURL("/wsdl/jms_test.wsdl"); HWByteMsgService service=new HWByteMsgService(wsdl,serviceName); String response1=new String("Hello Milestone-"); String response2=new String("Bonjour"); HelloWorldPortType greeter=service.getHWSByteMsgPort(); for (int idx=0; idx < 2; idx++) { String greeting=greeter.greetMe("Milestone-" + idx); assertNotNull("no response received from service",greeting); String exResponse=response1 + idx; assertEquals(exResponse,greeting); String reply=greeter.sayHi(); assertNotNull("no response received from service",reply); assertEquals(response2,reply); } ((java.io.Closeable)greeter).close(); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier IdentityVerifier EqualityVerifier IgnoredMethod HybridVerifier 
@Ignore @Test public void testAsyncCall() throws Exception { QName serviceName=new QName("http://cxf.apache.org/hello_world_jms","HelloWorldService"); QName portName=new QName("http://cxf.apache.org/hello_world_jms","HelloWorldPort"); URL wsdl=getWSDLURL("/wsdl/jms_test.wsdl"); HelloWorldService service=new HelloWorldService(wsdl,serviceName); HelloWorldPortType greeter=service.getPort(portName,HelloWorldPortType.class); final Thread thread=Thread.currentThread(); class TestAsyncHandler implements AsyncHandler { String expected; TestAsyncHandler( String x){ expected=x; } public String getExpected(){ return expected; } public void handleResponse( Response response){ try { Thread thread2=Thread.currentThread(); assertNotSame(thread,thread2); assertEquals("Hello " + expected,response.get()); } catch ( InterruptedException e) { e.printStackTrace(); } catch ( ExecutionException e) { e.printStackTrace(); } } } TestAsyncHandler h1=new TestAsyncHandler("Homer"); TestAsyncHandler h2=new TestAsyncHandler("Maggie"); TestAsyncHandler h3=new TestAsyncHandler("Bart"); TestAsyncHandler h4=new TestAsyncHandler("Lisa"); TestAsyncHandler h5=new TestAsyncHandler("Marge"); Future f1=greeter.greetMeAsync("Santa's Little Helper",new TestAsyncHandler("Santa's Little Helper")); f1.get(); f1=greeter.greetMeAsync("PauseForTwoSecs Santa's Little Helper",new TestAsyncHandler("Santa's Little Helper")); long start=System.currentTimeMillis(); f1=greeter.greetMeAsync("PauseForTwoSecs " + h1.getExpected(),h1); Future f2=greeter.greetMeAsync("PauseForTwoSecs " + h2.getExpected(),h2); Future f3=greeter.greetMeAsync("PauseForTwoSecs " + h3.getExpected(),h3); Future f4=greeter.greetMeAsync("PauseForTwoSecs " + h4.getExpected(),h4); Future f5=greeter.greetMeAsync("PauseForTwoSecs " + h5.getExpected(),h5); long mid=System.currentTimeMillis(); assertEquals("Hello " + h1.getExpected(),f1.get()); assertEquals("Hello " + h2.getExpected(),f2.get()); assertEquals("Hello " + h3.getExpected(),f3.get()); assertEquals("Hello " + h4.getExpected(),f4.get()); assertEquals("Hello " + h5.getExpected(),f5.get()); long end=System.currentTimeMillis(); assertTrue("Time too long: " + (mid - start),(mid - start) < 1000); assertTrue((end - mid) > 1000); f1=null; f2=null; f3=null; f4=null; f5=null; ((java.io.Closeable)greeter).close(); greeter=null; service=null; System.gc(); }

APIUtilityVerifier BranchVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testContextPropagation() throws Exception { final String testReturnPropertyName="Test_Prop"; final String testIgnoredPropertyName="Test_Prop_No_Return"; QName serviceName=new QName("http://cxf.apache.org/hello_world_jms","HelloWorldService"); QName portName=new QName("http://cxf.apache.org/hello_world_jms","HelloWorldPort"); URL wsdl=getWSDLURL("/wsdl/jms_test.wsdl"); HelloWorldService service=new HelloWorldService(wsdl,serviceName); HelloWorldPortType greeter=service.getPort(portName,HelloWorldPortType.class); Map requestContext=((BindingProvider)greeter).getRequestContext(); JMSMessageHeadersType requestHeader=new JMSMessageHeadersType(); requestHeader.setJMSCorrelationID("JMS_SAMPLE_CORRELATION_ID"); requestHeader.setJMSExpiration(3600000L); JMSPropertyType propType=new JMSPropertyType(); propType.setName(testReturnPropertyName); propType.setValue("mustReturn"); requestHeader.getProperty().add(propType); propType=new JMSPropertyType(); propType.setName(testIgnoredPropertyName); propType.setValue("mustNotReturn"); requestContext.put(JMSConstants.JMS_CLIENT_REQUEST_HEADERS,requestHeader); String greeting=greeter.greetMe("Milestone-"); assertNotNull("no response received from service",greeting); assertEquals("Hello Milestone-",greeting); Map responseContext=((BindingProvider)greeter).getResponseContext(); JMSMessageHeadersType responseHdr=(JMSMessageHeadersType)responseContext.get(JMSConstants.JMS_CLIENT_RESPONSE_HEADERS); if (responseHdr == null) { fail("response Header should not be null"); } assertTrue("CORRELATION ID should match :","JMS_SAMPLE_CORRELATION_ID".equals(responseHdr.getJMSCorrelationID())); assertTrue("response Headers must conain the app property set in request context.",responseHdr.getProperty() != null); boolean found=false; for ( JMSPropertyType p : responseHdr.getProperty()) { if (testReturnPropertyName.equals(p.getName())) { found=true; } } assertTrue("response Headers must match the app property set in request context.",found); ((Closeable)greeter).close(); }

IterativeVerifier UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testConnectionsWithinSpring() throws Exception { BusFactory.setDefaultBus(null); BusFactory.setThreadDefaultBus(null); ClassPathXmlApplicationContext ctx=new ClassPathXmlApplicationContext(new String[]{"/org/apache/cxf/systest/jms/JMSClients.xml"}); try { String wsdlString2="classpath:wsdl/jms_test.wsdl"; wsdlStrings.add(wsdlString2); broker.updateWsdl((Bus)ctx.getBean("cxf"),wsdlString2); HelloWorldPortType greeter=(HelloWorldPortType)ctx.getBean("jmsRPCClient"); try { for (int idx=0; idx < 5; idx++) { String greeting=greeter.greetMe("Milestone-" + idx); assertNotNull("no response received from service",greeting); String exResponse="Hello Milestone-" + idx; assertEquals(exResponse,greeting); String reply=greeter.sayHi(); assertEquals("Bonjour",reply); try { greeter.testRpcLitFault("BadRecordLitFault"); fail("Should have thrown BadRecoedLitFault"); } catch ( BadRecordLitFault ex) { assertNotNull(ex.getFaultInfo()); } try { greeter.testRpcLitFault("NoSuchCodeLitFault"); fail("Should have thrown NoSuchCodeLitFault exception"); } catch ( NoSuchCodeLitFault nslf) { assertNotNull(nslf.getFaultInfo()); assertNotNull(nslf.getFaultInfo().getCode()); } } } catch ( UndeclaredThrowableException ex) { ctx.close(); throw (Exception)ex.getCause(); } HelloWorldOneWayPort greeter1=(HelloWorldOneWayPort)ctx.getBean("jmsQueueOneWayServiceClient"); assertNotNull(greeter1); try { greeter1.greetMeOneWay("hello"); } catch ( Exception ex) { fail("There should not throw the exception" + ex); } } finally { ctx.close(); BusFactory.setDefaultBus(getBus()); BusFactory.setThreadDefaultBus(getBus()); } }

Class: org.apache.cxf.systest.jms.JMSTestMtom

EqualityVerifier PublicFieldVerifier 
@Test public void testMTOM() throws Exception { QName serviceName=new QName("http://cxf.apache.org/jms_mtom","JMSMTOMService"); QName portName=new QName("http://cxf.apache.org/jms_mtom","MTOMPort"); URL wsdl=getWSDLURL("/wsdl/jms_test_mtom.wsdl"); JMSMTOMService service=new JMSMTOMService(wsdl,serviceName); JMSMTOMPortType mtom=service.getPort(portName,JMSMTOMPortType.class); Binding binding=((BindingProvider)mtom).getBinding(); ((SOAPBinding)binding).setMTOMEnabled(true); Holder name=new Holder("Sam"); URL fileURL=this.getClass().getResource("/org/apache/cxf/systest/jms/JMSClientServerTest.class"); Holder handler1=new Holder(); handler1.value=new DataHandler(fileURL); int size=handler1.value.getInputStream().available(); mtom.testDataHandler(name,handler1); byte bytes[]=IOUtils.readBytesFromStream(handler1.value.getInputStream()); Assert.assertEquals("The response file is not same with the sent file.",size,bytes.length); ((Closeable)mtom).close(); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testOutMTOM() throws Exception { QName serviceName=new QName("http://cxf.apache.org/jms_mtom","JMSMTOMService"); QName portName=new QName("http://cxf.apache.org/jms_mtom","MTOMPort"); URL wsdl=getWSDLURL("/wsdl/jms_test_mtom.wsdl"); JMSOutMTOMService service=new JMSOutMTOMService(wsdl,serviceName); JMSMTOMPortType mtom=service.getPort(portName,JMSMTOMPortType.class); URL fileURL=this.getClass().getResource("/org/apache/cxf/systest/jms/JMSClientServerTest.class"); DataHandler handler1=new DataHandler(fileURL); int size=handler1.getInputStream().available(); DataHandler ret=mtom.testOutMtom(); byte bytes[]=IOUtils.readBytesFromStream(ret.getInputStream()); Assert.assertEquals("The response file is not same with the original file.",size,bytes.length); ((Closeable)mtom).close(); }

Class: org.apache.cxf.systest.jms.JaxWsAPITest

InternalCallVerifier EqualityVerifier 
@Test public void testGreeterUsingJaxWSAPI() throws Exception { QName serviceName=new QName("http://apache.org/hello_world_doc_lit","SOAPService2"); QName portName=new QName("http://apache.org/hello_world_doc_lit","SoapPort2"); URL wsdl=getWSDLURL("/wsdl/hello_world_doc_lit.wsdl"); SOAPService2 service=new SOAPService2(wsdl,serviceName); Greeter greeter=markForClose(service.getPort(portName,Greeter.class,cff)); Client client=ClientProxy.getClient(greeter); client.getEndpoint().getOutInterceptors().add(new TibcoSoapActionInterceptor()); greeter.greetMeOneWay("test String"); String greeting=greeter.greetMe("Chris"); Assert.assertEquals("Hello Chris",greeting); }

Class: org.apache.cxf.systest.jms.continuations.HelloWorldContinuationsClientServerTest

EqualityVerifier 
@Test public void testHelloWorldContinuations() throws Exception { QName serviceName=new QName("http://cxf.apache.org/systest/jaxws","HelloContinuationService"); URL wsdlURL=getClass().getClassLoader().getResource(WSDL_PATH); HelloContinuationService service=new HelloContinuationService(wsdlURL,serviceName); final HelloContinuation helloPort=markForClose(service.getPort(HelloContinuation.class,cff)); ExecutorService executor=Executors.newCachedThreadPool(); CountDownLatch startSignal=new CountDownLatch(1); CountDownLatch helloDoneSignal=new CountDownLatch(5); executor.execute(new HelloWorker(helloPort,"Fred","",startSignal,helloDoneSignal)); executor.execute(new HelloWorker(helloPort,"Barry","Jameson",startSignal,helloDoneSignal)); executor.execute(new HelloWorker(helloPort,"Harry","",startSignal,helloDoneSignal)); executor.execute(new HelloWorker(helloPort,"Rob","Davidson",startSignal,helloDoneSignal)); executor.execute(new HelloWorker(helloPort,"James","ServiceMix",startSignal,helloDoneSignal)); startSignal.countDown(); helloDoneSignal.await(60,TimeUnit.SECONDS); executor.shutdownNow(); Assert.assertEquals("Some invocations are still running",0,helloDoneSignal.getCount()); }

Class: org.apache.cxf.systest.jms.continuations.HelloWorldContinuationsThrottleTest

EqualityVerifier 
@Test public void testThrottleContinuations() throws Exception { QName serviceName=new QName("http://cxf.apache.org/systest/jaxws","HelloContinuationService"); URL wsdlURL=getClass().getClassLoader().getResource(WSDL_PATH); HelloContinuationService service=new HelloContinuationService(wsdlURL,serviceName); final HelloContinuation helloPort=markForClose(service.getPort(HelloContinuation.class,cff)); ThreadPoolExecutor executor=new ThreadPoolExecutor(5,5,0,TimeUnit.SECONDS,new ArrayBlockingQueue(10)); CountDownLatch startSignal=new CountDownLatch(1); CountDownLatch helloDoneSignal=new CountDownLatch(5); executor.execute(new HelloWorker(helloPort,"Fred","",startSignal,helloDoneSignal)); startSignal.countDown(); Thread.sleep(10000); executor.execute(new HelloWorker(helloPort,"Barry","Jameson",startSignal,helloDoneSignal)); executor.execute(new HelloWorker(helloPort,"Harry","",startSignal,helloDoneSignal)); executor.execute(new HelloWorker(helloPort,"Rob","Davidson",startSignal,helloDoneSignal)); executor.execute(new HelloWorker(helloPort,"James","ServiceMix",startSignal,helloDoneSignal)); helloDoneSignal.await(60,TimeUnit.SECONDS); executor.shutdownNow(); Assert.assertEquals("Some invocations are still running",0,helloDoneSignal.getCount()); }

Class: org.apache.cxf.systest.jms.continuations.JMSContinuationsClientServerTest

InternalCallVerifier EqualityVerifier 
@Test public void testContinuationWithTimeout() throws Exception { QName serviceName=new QName("http://cxf.apache.org/hello_world_jms","HelloWorldService"); QName portName=new QName("http://cxf.apache.org/hello_world_jms","HelloWorldPort"); URL wsdl=getWSDLURL("/org/apache/cxf/systest/jms/continuations/jms_test.wsdl"); HelloWorldService service=new HelloWorldService(wsdl,serviceName); HelloWorldPortType greeter=markForClose(service.getPort(portName,HelloWorldPortType.class,cff)); Assert.assertEquals("Hi Fred Ruby",greeter.greetMe("Fred")); }

Class: org.apache.cxf.systest.jms.multitransport.MultiTransportClientServerTest

IterativeVerifier UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testMultiTransportInOneService() throws Exception { QName portName1=new QName("http://apache.org/hello_world_doc_lit","HttpPort"); QName portName2=new QName("http://apache.org/hello_world_doc_lit","JMSPort"); URL wsdl=getClass().getResource("/wsdl/hello_world_doc_lit.wsdl"); Assert.assertNotNull(wsdl); MultiTransportService service=new MultiTransportService(wsdl,serviceName); String response1=new String("Hello Milestone-"); String response2=new String("Bonjour"); Greeter greeter=service.getPort(portName1,Greeter.class); TestUtil.updateAddressPort(greeter,PORT); for (int idx=0; idx < 5; idx++) { String greeting=greeter.greetMe("Milestone-" + idx); Assert.assertNotNull("no response received from service",greeting); String exResponse=response1 + idx; Assert.assertEquals(exResponse,greeting); String reply=greeter.sayHi(); Assert.assertNotNull("no response received from service",reply); Assert.assertEquals(response2,reply); try { greeter.pingMe(); Assert.fail("Should have thrown FaultException"); } catch ( PingMeFault ex) { Assert.assertNotNull(ex.getFaultInfo()); } } ((java.io.Closeable)greeter).close(); greeter=null; greeter=service.getPort(portName2,Greeter.class,cff); for (int idx=0; idx < 5; idx++) { String greeting=greeter.greetMe("Milestone-" + idx); Assert.assertNotNull("no response received from service",greeting); String exResponse=response1 + idx; Assert.assertEquals(exResponse,greeting); String reply=greeter.sayHi(); Assert.assertNotNull("no response received from service",reply); Assert.assertEquals(response2,reply); try { greeter.pingMe(); Assert.fail("Should have thrown FaultException"); } catch ( PingMeFault ex) { Assert.assertNotNull(ex.getFaultInfo()); } } ((java.io.Closeable)greeter).close(); }

Class: org.apache.cxf.systest.jms.security.JMSWSSecurityTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testUnsignedSAML2AudienceRestrictionTokenURI() throws Exception { QName serviceName=new QName("http://cxf.apache.org/hello_world_jms","HelloWorldService"); QName portName=new QName("http://cxf.apache.org/hello_world_jms","HelloWorldPort"); URL wsdl=getWSDLURL("/wsdl/jms_test.wsdl"); HelloWorldService service=new HelloWorldService(wsdl,serviceName); String response=new String("Bonjour"); HelloWorldPortType greeter=service.getPort(portName,HelloWorldPortType.class); SamlCallbackHandler callbackHandler=new SamlCallbackHandler(); callbackHandler.setSignAssertion(true); callbackHandler.setConfirmationMethod(SAML2Constants.CONF_BEARER); ConditionsBean conditions=new ConditionsBean(); conditions.setTokenPeriodMinutes(5); List audiences=new ArrayList<>(); audiences.add("jms:jndi:dynamicQueues/test.jmstransport.text"); AudienceRestrictionBean audienceRestrictionBean=new AudienceRestrictionBean(); audienceRestrictionBean.setAudienceURIs(audiences); conditions.setAudienceRestrictions(Collections.singletonList(audienceRestrictionBean)); callbackHandler.setConditions(conditions); Map outProperties=new HashMap(); outProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SAML_TOKEN_UNSIGNED); outProperties.put(WSHandlerConstants.SAML_CALLBACK_REF,callbackHandler); WSS4JOutInterceptor outInterceptor=new WSS4JOutInterceptor(outProperties); Client client=ClientProxy.getClient(greeter); client.getOutInterceptors().add(outInterceptor); String reply=greeter.sayHi(); assertNotNull("no response received from service",reply); assertEquals(response,reply); ((java.io.Closeable)greeter).close(); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testUnsignedSAML2Token() throws Exception { QName serviceName=new QName("http://cxf.apache.org/hello_world_jms","HelloWorldService"); QName portName=new QName("http://cxf.apache.org/hello_world_jms","HelloWorldPort"); URL wsdl=getWSDLURL("/wsdl/jms_test.wsdl"); HelloWorldService service=new HelloWorldService(wsdl,serviceName); String response=new String("Bonjour"); HelloWorldPortType greeter=service.getPort(portName,HelloWorldPortType.class); SamlCallbackHandler callbackHandler=new SamlCallbackHandler(); callbackHandler.setSignAssertion(true); callbackHandler.setConfirmationMethod(SAML2Constants.CONF_BEARER); Map outProperties=new HashMap(); outProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SAML_TOKEN_UNSIGNED); outProperties.put(WSHandlerConstants.SAML_CALLBACK_REF,callbackHandler); WSS4JOutInterceptor outInterceptor=new WSS4JOutInterceptor(outProperties); Client client=ClientProxy.getClient(greeter); client.getOutInterceptors().add(outInterceptor); String reply=greeter.sayHi(); assertNotNull("no response received from service",reply); assertEquals(response,reply); ((java.io.Closeable)greeter).close(); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testUnsignedSAML2AudienceRestrictionTokenServiceName() throws Exception { QName serviceName=new QName("http://cxf.apache.org/hello_world_jms","HelloWorldService"); QName portName=new QName("http://cxf.apache.org/hello_world_jms","HelloWorldPort"); URL wsdl=getWSDLURL("/wsdl/jms_test.wsdl"); HelloWorldService service=new HelloWorldService(wsdl,serviceName); String response=new String("Bonjour"); HelloWorldPortType greeter=service.getPort(portName,HelloWorldPortType.class); SamlCallbackHandler callbackHandler=new SamlCallbackHandler(); callbackHandler.setSignAssertion(true); callbackHandler.setConfirmationMethod(SAML2Constants.CONF_BEARER); ConditionsBean conditions=new ConditionsBean(); conditions.setTokenPeriodMinutes(5); List audiences=new ArrayList<>(); audiences.add("{http://cxf.apache.org/hello_world_jms}HelloWorldService"); AudienceRestrictionBean audienceRestrictionBean=new AudienceRestrictionBean(); audienceRestrictionBean.setAudienceURIs(audiences); conditions.setAudienceRestrictions(Collections.singletonList(audienceRestrictionBean)); callbackHandler.setConditions(conditions); Map outProperties=new HashMap(); outProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SAML_TOKEN_UNSIGNED); outProperties.put(WSHandlerConstants.SAML_CALLBACK_REF,callbackHandler); WSS4JOutInterceptor outInterceptor=new WSS4JOutInterceptor(outProperties); Client client=ClientProxy.getClient(greeter); client.getOutInterceptors().add(outInterceptor); String reply=greeter.sayHi(); assertNotNull("no response received from service",reply); assertEquals(response,reply); ((java.io.Closeable)greeter).close(); }

Class: org.apache.cxf.systest.jms.swa.ClientServerSwaTest

APIUtilityVerifier EqualityVerifier 
@Test public void testSwa() throws Exception { JaxWsProxyFactoryBean factory=new JaxWsProxyFactoryBean(); factory.setWsdlLocation("classpath:/swa-mime_jms.wsdl"); factory.setTransportId(SoapJMSConstants.SOAP_JMS_SPECIFICIATION_TRANSPORTID); factory.setServiceName(new QName("http://cxf.apache.org/swa","SwAService")); factory.setEndpointName(new QName("http://cxf.apache.org/swa","SwAServiceJMSPort")); factory.setAddress(ADDRESS + broker.getEncodedBrokerURL()); factory.getOutInterceptors().add(new LoggingOutInterceptor()); SwAService port=factory.create(SwAService.class); Holder textHolder=new Holder(); Holder data=new Holder(); ByteArrayDataSource source=new ByteArrayDataSource("foobar".getBytes(),"application/octet-stream"); DataHandler handler=new DataHandler(source); data.value=handler; textHolder.value="Hi"; port.echoData(textHolder,data); InputStream bis=null; bis=data.value.getDataSource().getInputStream(); byte b[]=new byte[10]; bis.read(b,0,10); String string=IOUtils.newStringFromBytes(b); assertEquals("testfoobar",string); assertEquals("Hi",textHolder.value); if (port instanceof Closeable) { ((Closeable)port).close(); } }

Class: org.apache.cxf.systest.js.JSClientServerTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testJSPayloadMode() throws Exception { URL wsdl=getClass().getResource("/wsdl/hello_world.wsdl"); assertNotNull(wsdl); QName serviceName=new QName(NS,"SOAPService_Test1"); QName portName=new QName(NS,"SoapPort_Test1"); SOAPServiceTest1 service=new SOAPServiceTest1(wsdl,serviceName); assertNotNull(service); String response1=new String("TestGreetMeResponse"); String response2=new String("TestSayHiResponse"); try { Greeter greeter=service.getPort(portName,Greeter.class); updateAddressPort(greeter,JSX_PORT); String greeting=greeter.greetMe("TestGreetMeRequest"); assertNotNull("no response received from service",greeting); assertEquals(response1,greeting); String reply=greeter.sayHi(); assertNotNull("no response received from service",reply); assertEquals(response2,reply); } catch ( UndeclaredThrowableException ex) { ex.printStackTrace(); throw (Exception)ex.getCause(); } }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testJSMessageMode() throws Exception { QName serviceName=new QName(NS,"SOAPService"); QName portName=new QName(NS,"SoapPort"); URL wsdl=getClass().getResource("/wsdl/hello_world.wsdl"); assertNotNull(wsdl); SOAPService service=new SOAPService(wsdl,serviceName); assertNotNull(service); String response1=new String("TestGreetMeResponse"); String response2=new String("TestSayHiResponse"); try { Greeter greeter=service.getPort(portName,Greeter.class); updateAddressPort(greeter,JS_PORT); String greeting=greeter.greetMe("TestGreetMeRequest"); assertNotNull("no response received from service",greeting); assertEquals(response1,greeting); String reply=greeter.sayHi(); assertNotNull("no response received from service",reply); assertEquals(response2,reply); } catch ( UndeclaredThrowableException ex) { ex.printStackTrace(); throw (Exception)ex.getCause(); } }

Class: org.apache.cxf.systest.kerberos.jaxrs.kerberos.JAXRSKerberosBookTest

InternalCallVerifier EqualityVerifier 
@Test public void testGetBookWithInterceptor() throws Exception { if (!runTests) { return; } WebClient wc=WebClient.create("http://localhost:" + PORT + "/bookstore/books/123"); KerberosAuthOutInterceptor kbInterceptor=new KerberosAuthOutInterceptor(); AuthorizationPolicy policy=new AuthorizationPolicy(); policy.setAuthorizationType(HttpAuthHeader.AUTH_TYPE_NEGOTIATE); policy.setAuthorization("alice"); policy.setUserName("alice"); policy.setPassword("alice"); kbInterceptor.setPolicy(policy); kbInterceptor.setCredDelegation(true); WebClient.getConfig(wc).getOutInterceptors().add(new LoggingOutInterceptor()); WebClient.getConfig(wc).getOutInterceptors().add(kbInterceptor); kbInterceptor.setServicePrincipalName("bob@service.ws.apache.org"); kbInterceptor.setServiceNameType(GSSName.NT_HOSTBASED_SERVICE); Book b=wc.get(Book.class); Assert.assertEquals(b.getId(),123); }

Class: org.apache.cxf.systest.lifecycle.LifeCycleTest

BranchVerifier BooleanVerifier InternalCallVerifier IdentityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetActiveFeatures(){ assertNotNull("unexpected non-null ServerLifeCycleManager",manager); manager.registerListener(new ServerLifeCycleListener(){ public void startServer( Server server){ org.apache.cxf.endpoint.Endpoint endpoint=server.getEndpoint(); updateMap(startNotificationMap,endpoint.getEndpointInfo().getAddress()); String portName=endpoint.getEndpointInfo().getName().getLocalPart(); if ("SoapPort".equals(portName)) { List active=endpoint.getActiveFeatures(); assertNotNull(active); assertEquals(1,active.size()); assertTrue(active.get(0) instanceof WSAddressingFeature); assertSame(active.get(0),AbstractFeature.getActive(active,WSAddressingFeature.class)); } else { List active=endpoint.getActiveFeatures(); assertNotNull(active); assertEquals(0,active.size()); assertNull(AbstractFeature.getActive(active,WSAddressingFeature.class)); } } public void stopServer( Server server){ updateMap(stopNotificationMap,server.getEndpoint().getEndpointInfo().getAddress()); } } ); Endpoint greeter=Endpoint.publish(ADDRESSES[0],new GreeterImpl()); Endpoint control=Endpoint.publish(ADDRESSES[1],new ControlImpl()); greeter.stop(); control.stop(); for (int i=0; i < 2; i++) { verifyNotification(startNotificationMap,ADDRESSES[i],1); verifyNotification(stopNotificationMap,ADDRESSES[i],1); } }

Class: org.apache.cxf.systest.management.CountersClientServerTest

APIUtilityVerifier IterativeVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCountersWithInstrumentationManager() throws Exception { Bus bus=getStaticBus(); BusFactory.setDefaultBus(bus); bus.getExtension(WorkQueueManager.class); CounterRepository cr=bus.getExtension(CounterRepository.class); InstrumentationManager im=bus.getExtension(InstrumentationManager.class); assertNotNull(im); InstrumentationManagerImpl impl=(InstrumentationManagerImpl)im; assertTrue(impl.isEnabled()); assertNotNull(impl.getMBeanServer()); MBeanServer mbs=im.getMBeanServer(); ObjectName name=new ObjectName(ManagementConstants.DEFAULT_DOMAIN_NAME + ":" + ManagementConstants.BUS_ID_PROP+ "=cxf"+ bus.hashCode()+ ",*"); SOAPService service=new SOAPService(); assertNotNull(service); Greeter greeter=service.getPort(portName,Greeter.class); updateAddressPort(greeter,PORT); String response=new String("Bonjour"); String reply=greeter.sayHi(); assertEquals("The Counters are not create yet",4,cr.getCounters().size()); Set counterNames=mbs.queryNames(name,null); assertEquals("The Counters are not export to JMX: " + counterNames,4 + 3,counterNames.size()); ObjectName sayHiCounter=new ObjectName(ManagementConstants.DEFAULT_DOMAIN_NAME + ":operation=\"sayHi\",*"); Set s=mbs.queryNames(sayHiCounter,null); Iterator it=s.iterator(); while (it.hasNext()) { ObjectName counterName=(ObjectName)it.next(); Object val=mbs.getAttribute(counterName,"NumInvocations"); assertEquals("Wrong Counters Number of Invocations",val,1); } reply=greeter.sayHi(); assertNotNull("no response received from service",reply); assertEquals(response,reply); s=mbs.queryNames(sayHiCounter,null); it=s.iterator(); while (it.hasNext()) { ObjectName counterName=(ObjectName)it.next(); Object val=mbs.getAttribute(counterName,"NumInvocations"); assertEquals("Wrong Counters Number of Invocations",val,2); } greeter.greetMeOneWay("hello"); for (int count=0; count < 10; count++) { if (6 != cr.getCounters().size()) { Thread.sleep(100); } else { break; } } assertEquals("The Counters are not create yet",6,cr.getCounters().size()); for (int count=0; count < 10; count++) { if (10 > mbs.queryNames(name,null).size()) { Thread.sleep(100); } else { break; } } counterNames=mbs.queryNames(name,null); assertEquals("The Counters are not export to JMX " + counterNames,6 + 4,counterNames.size()); ObjectName greetMeOneWayCounter=new ObjectName(ManagementConstants.DEFAULT_DOMAIN_NAME + ":operation=\"greetMeOneWay\",*"); s=mbs.queryNames(greetMeOneWayCounter,null); it=s.iterator(); while (it.hasNext()) { ObjectName counterName=(ObjectName)it.next(); Object val=mbs.getAttribute(counterName,"NumInvocations"); assertEquals("Wrong Counters Number of Invocations",val,1); } }

Class: org.apache.cxf.systest.management.ManagedBusTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testTwoSameNamedEndpoint() throws Exception { SpringBusFactory factory=new SpringBusFactory(); Bus bus=factory.createBus(); try { InstrumentationManager im=bus.getExtension(InstrumentationManager.class); assertNotNull(im); InstrumentationManagerImpl imi=(InstrumentationManagerImpl)im; imi.setServer(ManagementFactory.getPlatformMBeanServer()); imi.setEnabled(true); imi.init(); Greeter greeter1=new GreeterImpl(); JaxWsServerFactoryBean svrFactory=new JaxWsServerFactoryBean(); svrFactory.setAddress("http://localhost:" + SERVICE_PORT + "/Hello"); svrFactory.setServiceBean(greeter1); svrFactory.getProperties(true).put("managed.endpoint.name","greeter1"); svrFactory.create(); Greeter greeter2=new GreeterImpl(); svrFactory=new JaxWsServerFactoryBean(); svrFactory.setAddress("http://localhost:" + SERVICE_PORT + "/Hello2"); svrFactory.setServiceBean(greeter2); svrFactory.getProperties(true).put("managed.endpoint.name","greeter2"); svrFactory.create(); MBeanServer mbs=im.getMBeanServer(); ObjectName name=new ObjectName(ManagementConstants.DEFAULT_DOMAIN_NAME + ":type=Bus.Service.Endpoint,*"); Set s=mbs.queryMBeans(name,null); assertEquals(2,s.size()); } finally { bus.shutdown(true); } }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testManagedSpringBus() throws Exception { SpringBusFactory factory=new SpringBusFactory(); Bus bus=factory.createBus(); InstrumentationManager im=bus.getExtension(InstrumentationManager.class); assertNotNull(im); InstrumentationManagerImpl imi=(InstrumentationManagerImpl)im; assertEquals("service:jmx:rmi:///jndi/rmi://localhost:9913/jmxrmi",imi.getJMXServiceURL()); assertTrue(!imi.isEnabled()); assertNull(imi.getMBeanServer()); im.register(imi,new ObjectName("org.apache.cxf:foo=bar")); bus.shutdown(true); }

Class: org.apache.cxf.systest.management.ManagedClientServerTest

APIUtilityVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testManagedEndpoint() throws Exception { Bus bus=getStaticBus(); BusFactory.setDefaultBus(bus); InstrumentationManager im=bus.getExtension(InstrumentationManager.class); assertNotNull(im); InstrumentationManagerImpl impl=(InstrumentationManagerImpl)im; assertTrue(impl.isEnabled()); assertNotNull(impl.getMBeanServer()); MBeanServer mbs=im.getMBeanServer(); ObjectName name=new ObjectName(ManagementConstants.DEFAULT_DOMAIN_NAME + ":type=Bus.Service.Endpoint,*"); Set s=mbs.queryNames(name,null); assertEquals(1,s.size()); name=(ObjectName)s.iterator().next(); Object val=mbs.invoke(name,"getState",new Object[0],new String[0]); assertEquals("Service should have been started.","STARTED",val); SOAPService service=new SOAPService(); assertNotNull(service); Greeter greeter=service.getPort(portName,Greeter.class); updateAddressPort(greeter,PORT); String response=new String("Bonjour"); String reply=greeter.sayHi(); assertNotNull("no response received from service",reply); assertEquals(response,reply); mbs.invoke(name,"stop",new Object[0],new String[0]); val=mbs.getAttribute(name,"State"); assertEquals("Service should have been stopped.","STOPPED",val); try { reply=greeter.sayHi(); fail("Endpoint should not be active at this point."); } catch ( Exception ex) { } mbs.invoke(name,"start",new Object[0],new String[0]); val=mbs.invoke(name,"getState",new Object[0],new String[0]); assertEquals("Service should have been started.","STARTED",val); reply=greeter.sayHi(); assertNotNull("no response received from service",reply); assertEquals(response,reply); mbs.invoke(name,"destroy",new Object[0],new String[0]); try { mbs.getMBeanInfo(name); fail("destroy failed to unregister MBean."); } catch ( InstanceNotFoundException e) { } }

Class: org.apache.cxf.systest.mtom.ClientMtomXopTest

EqualityVerifier NullVerifier HybridVerifier 
@Test public void testMtomWithFileName() throws Exception { TestMtom mtomPort=createPort(MTOM_SERVICE,MTOM_PORT,TestMtom.class,true,true); try { Holder param=new Holder(); Holder name; URL fileURL=getClass().getClassLoader().getResource("me.bmp"); Object[] validationTypes=new Object[]{Boolean.TRUE,SchemaValidationType.IN,SchemaValidationType.BOTH}; for ( Object validationType : validationTypes) { ((BindingProvider)mtomPort).getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED,validationType); param.value=new DataHandler(fileURL); name=new Holder("have name"); mtomPort.testXop(name,param); assertEquals("can't get file name","return detail + me.bmp",name.value); assertNotNull(param.value); } } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } catch ( Exception ex) { if (ex.getMessage().contains("Connection reset") && System.getProperty("java.specification.version","1.5").contains("1.6")) { return; } System.out.println(System.getProperties()); throw ex; } }

APIUtilityVerifier EqualityVerifier NullVerifier PublicFieldVerifier HybridVerifier 
@Test public void testMtomXop() throws Exception { TestMtom mtomPort=createPort(MTOM_SERVICE,MTOM_PORT,TestMtom.class,true,true); try { Holder param=new Holder(); Holder name; byte bytes[]; InputStream in; InputStream pre=this.getClass().getResourceAsStream("/wsdl/mtom_xop.wsdl"); int fileSize=0; for (int i=pre.read(); i != -1; i=pre.read()) { fileSize++; } int count=50; byte[] data=new byte[fileSize * count]; for (int x=0; x < count; x++) { this.getClass().getResourceAsStream("/wsdl/mtom_xop.wsdl").read(data,fileSize * x,fileSize); } Object[] validationTypes=new Object[]{Boolean.TRUE,SchemaValidationType.IN,SchemaValidationType.BOTH}; for ( Object validationType : validationTypes) { ((BindingProvider)mtomPort).getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED,validationType); param.value=new DataHandler(new ByteArrayDataSource(data,"application/octet-stream")); name=new Holder("call detail"); mtomPort.testXop(name,param); assertEquals("name unchanged","return detail + call detail",name.value); assertNotNull(param.value); in=param.value.getInputStream(); bytes=IOUtils.readBytesFromStream(in); assertEquals(data.length,bytes.length); in.close(); param.value=new DataHandler(new ByteArrayDataSource(data,"application/octet-stream")); name=new Holder("call detail"); mtomPort.testXop(name,param); assertEquals("name unchanged","return detail + call detail",name.value); assertNotNull(param.value); in=param.value.getInputStream(); bytes=IOUtils.readBytesFromStream(in); assertEquals(data.length,bytes.length); in.close(); } validationTypes=new Object[]{Boolean.FALSE,SchemaValidationType.OUT,SchemaValidationType.NONE}; for ( Object validationType : validationTypes) { ((BindingProvider)mtomPort).getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED,validationType); SAAJOutInterceptor saajOut=new SAAJOutInterceptor(); SAAJInInterceptor saajIn=new SAAJInInterceptor(); param.value=new DataHandler(new ByteArrayDataSource(data,"application/octet-stream")); name=new Holder("call detail"); mtomPort.testXop(name,param); assertEquals("name unchanged","return detail + call detail",name.value); assertNotNull(param.value); in=param.value.getInputStream(); bytes=IOUtils.readBytesFromStream(in); assertEquals(data.length,bytes.length); in.close(); ClientProxy.getClient(mtomPort).getInInterceptors().add(saajIn); ClientProxy.getClient(mtomPort).getInInterceptors().add(saajOut); param.value=new DataHandler(new ByteArrayDataSource(data,"application/octet-stream")); name=new Holder("call detail"); mtomPort.testXop(name,param); assertEquals("name unchanged","return detail + call detail",name.value); assertNotNull(param.value); in=param.value.getInputStream(); bytes=IOUtils.readBytesFromStream(in); assertEquals(data.length,bytes.length); in.close(); ClientProxy.getClient(mtomPort).getInInterceptors().remove(saajIn); ClientProxy.getClient(mtomPort).getInInterceptors().remove(saajOut); } } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } catch ( Exception ex) { if (ex.getMessage().contains("Connection reset") && System.getProperty("java.specification.version","1.5").contains("1.6")) { return; } System.out.println(System.getProperties()); throw ex; } }

Class: org.apache.cxf.systest.mtom.ClientMtomXopWithJMSTest

EqualityVerifier NullVerifier HybridVerifier 
@Test public void testMtomXop() throws Exception { TestMtom mtomPort=createPort(MTOM_SERVICE,MTOM_PORT,TestMtom.class,true); InputStream pre=this.getClass().getResourceAsStream("/wsdl/mtom_xop.wsdl"); int fileSize=0; for (int i=pre.read(); i != -1; i=pre.read()) { fileSize++; } Holder param=new Holder(); int count=50; byte[] data=new byte[fileSize * count]; for (int x=0; x < count; x++) { this.getClass().getResourceAsStream("/wsdl/mtom_xop.wsdl").read(data,fileSize * x,fileSize); } param.value=new DataHandler(new ByteArrayDataSource(data,"application/octet-stream")); Holder name=new Holder("call detail"); mtomPort.testXop(name,param); Assert.assertEquals("name unchanged","return detail + call detail",name.value); Assert.assertNotNull(param.value); param.value.getInputStream().close(); }

Class: org.apache.cxf.systest.mtom.MtomServerTest

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testURLBasedAttachment() throws Exception { JaxWsServerFactoryBean sf=new JaxWsServerFactoryBean(); sf.setServiceBean(new EchoService()); sf.setBus(getStaticBus()); String address="http://localhost:" + PORT2 + "/EchoService"; sf.setAddress(address); Map props=new HashMap(); props.put(Message.MTOM_ENABLED,"true"); sf.setProperties(props); Server server=sf.create(); server.getEndpoint().getService().getDataBinding().setMtomThreshold(0); servStatic(getClass().getResource("mtom-policy.xml"),"http://localhost:" + PORT2 + "/policy.xsd"); EndpointInfo ei=new EndpointInfo(null,HTTP_ID); ei.setAddress(address); ConduitInitiatorManager conduitMgr=getStaticBus().getExtension(ConduitInitiatorManager.class); ConduitInitiator conduitInit=conduitMgr.getConduitInitiator("http://schemas.xmlsoap.org/soap/http"); Conduit conduit=conduitInit.getConduit(ei,getStaticBus()); TestUtilities.TestMessageObserver obs=new TestUtilities.TestMessageObserver(); conduit.setMessageObserver(obs); Message m=new MessageImpl(); String ct="multipart/related; type=\"application/xop+xml\"; " + "start=\"\"; " + "start-info=\"text/xml; charset=utf-8\"; "+ "boundary=\"----=_Part_4_701508.1145579811786\""; m.put(Message.CONTENT_TYPE,ct); conduit.prepare(m); OutputStream os=m.getContent(OutputStream.class); InputStream is=testUtilities.getResourceAsStream("request-url-attachment"); if (is == null) { throw new RuntimeException("Could not find resource " + "request"); } ByteArrayOutputStream bout=new ByteArrayOutputStream(); IOUtils.copy(is,bout); String s=bout.toString(StandardCharsets.UTF_8.name()); s=s.replaceAll(":9036/",":" + PORT2 + "/"); os.write(s.getBytes(StandardCharsets.UTF_8)); os.flush(); is.close(); os.close(); byte[] res=obs.getResponseStream().toByteArray(); MessageImpl resMsg=new MessageImpl(); resMsg.setContent(InputStream.class,new ByteArrayInputStream(res)); resMsg.put(Message.CONTENT_TYPE,obs.getResponseContentType()); resMsg.setExchange(new ExchangeImpl()); AttachmentDeserializer deserializer=new AttachmentDeserializer(resMsg); deserializer.initializeAttachments(); Collection attachments=resMsg.getAttachments(); assertNotNull(attachments); assertEquals(1,attachments.size()); Attachment inAtt=attachments.iterator().next(); ByteArrayOutputStream out=new ByteArrayOutputStream(); IOUtils.copy(inAtt.getDataHandler().getInputStream(),out); out.close(); assertTrue("Wrong size: " + out.size() + "\n"+ out.toString(),out.size() > 970 && out.size() < 1020); unregisterServStatic("http://localhost:" + PORT2 + "/policy.xsd"); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testMtomRequest() throws Exception { JaxWsServerFactoryBean sf=new JaxWsServerFactoryBean(); sf.setServiceBean(new EchoService()); sf.setBus(getStaticBus()); String address="http://localhost:" + PORT1 + "/EchoService"; sf.setAddress(address); Map props=new HashMap(); props.put(Message.MTOM_ENABLED,"true"); sf.setProperties(props); sf.create(); EndpointInfo ei=new EndpointInfo(null,HTTP_ID); ei.setAddress(address); ConduitInitiatorManager conduitMgr=getStaticBus().getExtension(ConduitInitiatorManager.class); ConduitInitiator conduitInit=conduitMgr.getConduitInitiator("http://schemas.xmlsoap.org/soap/http"); Conduit conduit=conduitInit.getConduit(ei,getStaticBus()); TestUtilities.TestMessageObserver obs=new TestUtilities.TestMessageObserver(); conduit.setMessageObserver(obs); Message m=new MessageImpl(); String ct="multipart/related; type=\"application/xop+xml\"; " + "start=\"\"; " + "start-info=\"text/xml\"; "+ "boundary=\"----=_Part_4_701508.1145579811786\""; m.put(Message.CONTENT_TYPE,ct); conduit.prepare(m); OutputStream os=m.getContent(OutputStream.class); InputStream is=testUtilities.getResourceAsStream("request"); if (is == null) { throw new RuntimeException("Could not find resource " + "request"); } IOUtils.copy(is,os); os.flush(); is.close(); os.close(); byte[] res=obs.getResponseStream().toByteArray(); MessageImpl resMsg=new MessageImpl(); resMsg.setContent(InputStream.class,new ByteArrayInputStream(res)); resMsg.put(Message.CONTENT_TYPE,obs.getResponseContentType()); resMsg.setExchange(new ExchangeImpl()); AttachmentDeserializer deserializer=new AttachmentDeserializer(resMsg); deserializer.initializeAttachments(); Collection attachments=resMsg.getAttachments(); assertNotNull(attachments); assertEquals(1,attachments.size()); Attachment inAtt=attachments.iterator().next(); ByteArrayOutputStream out=new ByteArrayOutputStream(); IOUtils.copy(inAtt.getDataHandler().getInputStream(),out); out.close(); assertEquals(27364,out.size()); }

Class: org.apache.cxf.systest.mtom_bindingtype.MTOMBindingTypeTest

BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDetail() throws Exception { ByteArrayOutputStream input=setupInLogging(); ByteArrayOutputStream output=setupOutLogging(); Holder photo=new Holder("CXF".getBytes()); Holder image=new Holder(getImage("/java.jpg")); Hello port=getPort(); SOAPBinding binding=(SOAPBinding)((BindingProvider)port).getBinding(); binding.setMTOMEnabled(true); port.detail(photo,image); String expected="

Class: org.apache.cxf.systest.mtom_feature.MtomFeatureClientServerTest

EqualityVerifier NullVerifier HybridVerifier 
@Test public void testWithLocalTransport() throws Exception { Object implementor=new HelloImpl(); String address="local://Hello"; Endpoint.publish(address,implementor); QName portName=new QName("http://apache.org/cxf/systest/mtom_feature","HelloPort"); Service service=Service.create(serviceName); service.addPort(portName,"http://schemas.xmlsoap.org/soap/","local://Hello"); port=service.getPort(portName,Hello.class,new MTOMFeature()); ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,address); ((BindingProvider)port).getRequestContext().put(LocalConduit.DIRECT_DISPATCH,Boolean.TRUE); Holder photo=new Holder("CXF".getBytes()); Holder image=new Holder(getImage("/java.jpg")); port.detail(photo,image); assertEquals("CXF",new String(photo.value)); assertNotNull(image.value); ((BindingProvider)port).getRequestContext().put(LocalConduit.DIRECT_DISPATCH,Boolean.FALSE); photo=new Holder("CXF".getBytes()); image=new Holder(getImage("/java.jpg")); port.detail(photo,image); assertEquals("CXF",new String(photo.value)); assertNotNull(image.value); }

EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDetail() throws Exception { Holder photo=new Holder("CXF".getBytes()); Holder image=new Holder(getImage("/java.jpg")); port.detail(photo,image); assertEquals("CXF",new String(photo.value)); assertNotNull(image.value); }

Class: org.apache.cxf.systest.mtom_schema_validation.MTOMProviderSchemaValidationTest

InternalCallVerifier EqualityVerifier 
@Test public void testSchemaValidation() throws Exception { HelloWS port=createService(); Hello request=new Hello(); request.setArg0("value"); URL wsdl=getClass().getResource("/wsdl_systest/mtom_provider_validate.wsdl"); File attachment=new File(wsdl.getFile()); request.setFile(new DataHandler(new FileDataSource(attachment))); HelloResponse response=port.hello(request); assertEquals("Hello CXF",response.getReturn()); }

Class: org.apache.cxf.systest.nested_callback.CallbackClientServerTest

InternalCallVerifier EqualityVerifier 
@Test public void testCallback() throws Exception { Object implementor=new CallbackImpl(); String address="http://localhost:" + CB_PORT + "/CallbackContext/NestedCallbackPort"; Endpoint.publish(address,implementor); URL wsdlURL=getClass().getResource("/wsdl/nested_callback.wsdl"); SOAPService ss=new SOAPService(wsdlURL,SERVICE_NAME); ServerPortType port=ss.getPort(PORT_NAME,ServerPortType.class); updateAddressPort(port,PORT); EndpointReferenceType ref=null; try { ref=EndpointReferenceUtils.getEndpointReference(wsdlURL,SERVICE_NAME_CALLBACK,PORT_NAME_CALLBACK.getLocalPart()); EndpointReferenceUtils.setInterfaceName(ref,PORT_TYPE_CALLBACK); EndpointReferenceUtils.setAddress(ref,address); } catch ( Exception e) { e.printStackTrace(); } NestedCallback callbackObject=new NestedCallback(); Source source=EndpointReferenceUtils.convertToXML(ref); W3CEndpointReference w3cEpr=new W3CEndpointReference(source); callbackObject.setCallback(w3cEpr); String resp=port.registerCallback(callbackObject); assertEquals("registerCallback called",resp); }

Class: org.apache.cxf.systest.provider.AttachmentProviderXMLClientServerTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testRequestWithAttachment() throws Exception { HttpURLConnection connection=(HttpURLConnection)new URL(ADDRESS).openConnection(); connection.setRequestMethod("POST"); String ct="multipart/related; type=\"text/xml\"; " + "start=\"rootPart\"; " + "boundary=\"----=_Part_4_701508.1145579811786\""; connection.addRequestProperty("Content-Type",ct); connection.setDoOutput(true); InputStream is=getClass().getResourceAsStream("attachmentData"); IOUtils.copy(is,connection.getOutputStream()); connection.getOutputStream().close(); is.close(); assertTrue("wrong content type: " + connection.getContentType(),connection.getContentType().contains("multipart/related")); String input=IOUtils.toString(connection.getInputStream()); int idx=input.indexOf("--uuid"); int idx2=input.indexOf("--uuid",idx + 5); String root=input.substring(idx,idx2); idx=root.indexOf("\r\n\r\n"); root=root.substring(idx).trim(); Document result=StaxUtils.read(new StringReader(root)); List resList=DOMUtils.findAllElementsByTagName(result.getDocumentElement(),"att"); assertEquals("Two attachments must've been encoded",2,resList.size()); verifyAttachment(resList,"foo","foobar"); verifyAttachment(resList,"bar","barbaz"); input=input.substring(idx2); assertTrue(input.contains("")); assertTrue(input.contains("ABCDEFGHIJKLMNOP")); }

Class: org.apache.cxf.systest.provider.CXF4130Test

APIUtilityVerifier IterativeVerifier BranchVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testCxf4130() throws Exception { InputStream body=getClass().getResourceAsStream("cxf4130data.txt"); HttpClient client=new HttpClient(); PostMethod post=new PostMethod(ADDRESS); post.setRequestEntity(new InputStreamRequestEntity(body,"text/xml")); client.executeMethod(post); Document doc=StaxUtils.read(post.getResponseBodyAsStream()); Element root=doc.getDocumentElement(); Node child=root.getFirstChild(); boolean foundBody=false; while (child != null) { if ("Body".equals(child.getLocalName())) { foundBody=true; assertEquals(1,child.getChildNodes().getLength()); assertEquals("FooResponse",child.getFirstChild().getLocalName()); } child=child.getNextSibling(); } assertTrue("Did not find the soap:Body element",foundBody); }

Class: org.apache.cxf.systest.provider.InterpretNullAsOnewayProviderTest

APIUtilityVerifier EqualityVerifier 
@Test public void testInterpretNullAsOneway() throws Exception { HttpURLConnection conn=postRequest(ADDRESS3); assertEquals("http 202 must be returned",202,conn.getResponseCode()); }

Class: org.apache.cxf.systest.provider.NBProviderClientServerTest

APIUtilityVerifier UtilityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSOAPMessageModeDocLit() throws Exception { QName serviceName=new QName("http://apache.org/hello_world_soap_http","SOAPProviderService"); QName portName=new QName("http://apache.org/hello_world_soap_http","SoapProviderPort"); Service service=Service.create(serviceName); assertNotNull(service); service.addPort(portName,SOAPBinding.SOAP11HTTP_BINDING,ADDRESS); try { Dispatch dispatch=service.createDispatch(portName,SOAPMessage.class,Service.Mode.MESSAGE); MessageFactory factory=MessageFactory.newInstance(); SOAPMessage request=encodeRequest(factory,"sayHi"); SOAPMessage response; try { response=dispatch.invoke(request); fail("Should have thrown an exception"); } catch ( Exception ex) { assertEquals("no body expected",ex.getMessage()); } request=encodeRequest(factory,null); response=dispatch.invoke(request); String resp=decodeResponse(response); assertEquals("Bonjour",resp); } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

Class: org.apache.cxf.systest.provider.ProviderClientServerTest

IterativeVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSOAPMessageModeDocLit() throws Exception { QName serviceName=new QName("http://apache.org/hello_world_soap_http","SOAPProviderService"); QName portName=new QName("http://apache.org/hello_world_soap_http","SoapProviderPort"); URL wsdl=getClass().getResource("/wsdl/hello_world.wsdl"); assertNotNull(wsdl); SOAPService service=new SOAPService(wsdl,serviceName); assertNotNull(service); String response1=new String("TestSOAPOutputPMessage"); String response2=new String("Bonjour"); try { Greeter greeter=service.getPort(portName,Greeter.class); setAddress(greeter,ADDRESS); try { greeter.greetMe("Return sayHi"); fail("Should have thrown an exception"); } catch ( Exception ex) { assertTrue(ex.getMessage().contains("sayHiResponse")); } for (int idx=0; idx < 2; idx++) { String greeting=greeter.greetMe("Milestone-" + idx); assertNotNull("no response received from service",greeting); assertEquals(response1,greeting); String reply=greeter.sayHi(); assertNotNull("no response received from service",reply); assertEquals(response2,reply); } try { greeter.greetMe("throwFault"); fail("Expected a fault"); } catch ( SOAPFaultException ex) { assertTrue(ex.getMessage().contains("Test Fault String")); } } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

Class: org.apache.cxf.systest.provider.ProviderRPCClientServerTest

APIUtilityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSWA() throws Exception { SOAPFactory soapFac=SOAPFactory.newInstance(); MessageFactory msgFac=MessageFactory.newInstance(); SOAPConnectionFactory conFac=SOAPConnectionFactory.newInstance(); SOAPMessage msg=msgFac.createMessage(); QName sayHi=new QName("http://apache.org/hello_world_rpclit","sayHiWAttach"); msg.getSOAPBody().addChildElement(soapFac.createElement(sayHi)); AttachmentPart ap1=msg.createAttachmentPart(); ap1.setContent("Attachment content","text/plain"); msg.addAttachmentPart(ap1); AttachmentPart ap2=msg.createAttachmentPart(); ap2.setContent("Attachment content - Part 2","text/plain"); msg.addAttachmentPart(ap2); msg.saveChanges(); SOAPConnection con=conFac.createConnection(); URL endpoint=new URL("http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit1"); SOAPMessage response=con.call(msg,endpoint); QName sayHiResp=new QName("http://apache.org/hello_world_rpclit","sayHiResponse"); assertNotNull(response.getSOAPBody().getChildElements(sayHiResp)); assertEquals(2,response.countAttachments()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSOAPMessageModeRPC() throws Exception { QName serviceName=new QName("http://apache.org/hello_world_rpclit","SOAPServiceProviderRPCLit"); QName portName=new QName("http://apache.org/hello_world_rpclit","SoapPortProviderRPCLit1"); URL wsdl=getClass().getResource("/wsdl/hello_world_rpc_lit.wsdl"); assertNotNull(wsdl); SOAPServiceRPCLit service=new SOAPServiceRPCLit(wsdl,serviceName); assertNotNull(service); String response1=new String("TestGreetMeResponseServerLogicalHandlerServerSOAPHandler"); String response2=new String("TestSayHiResponse"); GreeterRPCLit greeter=service.getPort(portName,GreeterRPCLit.class); updateAddressPort(greeter,PORT); String greeting=greeter.greetMe("Milestone-0"); assertNotNull("no response received from service",greeting); assertEquals(response1,greeting); String reply=greeter.sayHi(); assertNotNull("no response received from service",reply); assertEquals(response2,reply); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testPayloadModeWithSourceData() throws Exception { URL wsdl=getClass().getResource("/wsdl/hello_world_rpc_lit.wsdl"); assertNotNull(wsdl); QName serviceName=new QName("http://apache.org/hello_world_rpclit","SOAPServiceProviderRPCLit"); QName portName=new QName("http://apache.org/hello_world_rpclit","SoapPortProviderRPCLit8"); SOAPServiceRPCLit service=new SOAPServiceRPCLit(wsdl,serviceName); assertNotNull(service); String addresses[]={"http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8","http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8-dom","http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8-sax","http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8-cxfstax","http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8-stax","http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8-stream"}; String response1=new String("TestGreetMeResponseServerLogicalHandlerServerSOAPHandler"); GreeterRPCLit greeter=service.getPort(portName,GreeterRPCLit.class); for ( String ad : addresses) { ((BindingProvider)greeter).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,ad); String greeting=greeter.greetMe("Milestone-0"); assertNotNull("no response received from service " + ad,greeting); assertEquals("wrong response received from service " + ad,response1,greeting); } }

Class: org.apache.cxf.systest.provider.ProviderXMLClientServerTest

APIUtilityVerifier UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDOMSourcePAYLOAD() throws Exception { URL wsdl=getClass().getResource("/wsdl/hello_world_xml_wrapped.wsdl"); assertNotNull(wsdl); XMLService service=new XMLService(wsdl,serviceName); assertNotNull(service); InputStream is=getClass().getResourceAsStream("/messages/XML_GreetMeDocLiteralReq.xml"); Document doc=StaxUtils.read(is); DOMSource reqMsg=new DOMSource(doc); assertNotNull(reqMsg); Dispatch disp=service.createDispatch(portName,DOMSource.class,Service.Mode.PAYLOAD); setAddress(disp,ADDRESS); DOMSource result=disp.invoke(reqMsg); assertNotNull(result); Node respDoc=result.getNode(); assertEquals("greetMeResponse",respDoc.getFirstChild().getLocalName()); assertEquals("TestXMLBindingProviderMessage",respDoc.getFirstChild().getTextContent()); is=getClass().getResourceAsStream("/messages/XML_GreetMeDocLiteralReq_invalid.xml"); doc=StaxUtils.read(is); reqMsg=new DOMSource(doc); assertNotNull(reqMsg); disp=service.createDispatch(portName,DOMSource.class,Service.Mode.PAYLOAD); try { setAddress(disp,ADDRESS); result=disp.invoke(reqMsg); fail("should have a schema validation exception of some sort"); } catch ( Exception ex) { } }

APIUtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testEmptyPost() throws Exception { URL url=new URL(ADDRESS); HttpURLConnection connection=(HttpURLConnection)url.openConnection(); connection.setRequestMethod("POST"); connection.setDoInput(true); int i=connection.getResponseCode(); assertEquals(200,i); assertTrue(connection.getContentType().indexOf("xml") != -1); }

Class: org.apache.cxf.systest.provider.datasource.DataSourceProviderTest

APIUtilityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void postAttachmentToServer() throws Exception { String contentType="multipart/related; type=\"text/xml\"; " + "start=\"attachmentData\"; " + "boundary=\"" + BOUNDARY + "\""; InputStream in=getClass().getResourceAsStream("/attachmentBinaryData"); assertNotNull("could not load test data",in); conn.setRequestMethod("POST"); conn.addRequestProperty("Content-Type",contentType); OutputStream out=conn.getOutputStream(); IOUtils.copy(in,out); out.close(); MimeMultipart mm=readAttachmentParts(conn.getContentType(),conn.getInputStream()); assertEquals("incorrect number of parts received by server",3,mm.getCount()); }

Class: org.apache.cxf.systest.servlet.CXFFilterTest

InternalCallVerifier EqualityVerifier 
@Test public void testGetServiceList() throws Exception { ServletUnitClient client=newClient(); client.setExceptionsThrownOnErrorStatus(false); WebResponse res=client.getResponse(CONTEXT_URL + "/"); WebLink[] links=res.getLinks(); assertEquals("Wrong number of service links",3,links.length); Set links2=new HashSet(); for ( WebLink l : links) { links2.add(l.getURLString()); } assertEquals("text/html",res.getContentType()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testPostInvokeServices() throws Exception { newClient(); WebRequest req=new PostMethodWebRequest(CONTEXT_URL + "/services/Greeter",getClass().getResourceAsStream("GreeterMessage.xml"),"text/xml; charset=UTF-8"); WebResponse response=newClient().getResponse(req); assertEquals("text/xml",response.getContentType()); assertEquals(StandardCharsets.UTF_8.name(),response.getCharacterSet()); Document doc=StaxUtils.read(response.getInputStream()); assertNotNull(doc); addNamespace("h","http://apache.org/hello_world_soap_http/types"); assertValid("/s:Envelope/s:Body",doc); assertValid("//h:sayHiResponse",doc); }

Class: org.apache.cxf.systest.servlet.CXFServletTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetWSDL() throws Exception { ServletUnitClient client=newClient(); client.setExceptionsThrownOnErrorStatus(true); WebRequest req=new GetMethodQueryWebRequest(CONTEXT_URL + "/services/greeter?wsdl"); WebResponse res=client.getResponse(req); assertEquals(200,res.getResponseCode()); assertEquals("text/xml",res.getContentType()); Document doc=StaxUtils.read(res.getInputStream()); assertNotNull(doc); assertValid("//wsdl:operation[@name='greetMe']",doc); assertValid("//wsdlsoap:address[@location='" + CONTEXT_URL + "/services/greeter']",doc); }

InternalCallVerifier EqualityVerifier 
@Test public void testInvalidServiceUrl() throws Exception { ServletUnitClient client=newClient(); client.setExceptionsThrownOnErrorStatus(false); WebResponse res=client.getResponse(CONTEXT_URL + "/services/NoSuchService"); assertEquals(404,res.getResponseCode()); assertEquals("text/html",res.getContentType()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetWSDLWithIncludes() throws Exception { ServletUnitClient client=newClient(); client.setExceptionsThrownOnErrorStatus(true); WebRequest req=new GetMethodQueryWebRequest(CONTEXT_URL + "/services/greeter3?wsdl"); WebResponse res=client.getResponse(req); assertEquals(200,res.getResponseCode()); assertEquals("text/xml",res.getContentType()); Document doc=StaxUtils.read(res.getInputStream()); assertNotNull(doc); assertXPathEquals("//xsd:include/@schemaLocation","http://localhost/mycontext/services/greeter3?xsd=hello_world_includes2.xsd",doc.getDocumentElement()); req=new GetMethodQueryWebRequest(CONTEXT_URL + "/services/greeter3?xsd=hello_world_includes2.xsd"); res=client.getResponse(req); assertEquals(200,res.getResponseCode()); assertEquals("text/xml",res.getContentType()); doc=StaxUtils.read(res.getInputStream()); assertNotNull(doc); assertValid("//xsd:complexType[@name='ErrorCode']",doc); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testGetImportedXSD() throws Exception { ServletUnitClient client=newClient(); client.setExceptionsThrownOnErrorStatus(true); WebRequest req=new GetMethodQueryWebRequest(CONTEXT_URL + "/services/greeter?wsdl"); WebResponse res=client.getResponse(req); assertEquals(200,res.getResponseCode()); String text=res.getText(); assertEquals("text/xml",res.getContentType()); assertTrue(text.contains(CONTEXT_URL + "/services/greeter?wsdl=test_import.xsd")); req=new GetMethodQueryWebRequest(CONTEXT_URL + "/services/greeter?wsdl=test_import.xsd"); res=client.getResponse(req); assertEquals(200,res.getResponseCode()); text=res.getText(); assertEquals("text/xml",res.getContentType()); assertTrue("the xsd should contain the completType SimpleStruct",text.contains("")); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetServiceList() throws Exception { ServletUnitClient client=newClient(); client.setExceptionsThrownOnErrorStatus(false); WebResponse res=client.getResponse(CONTEXT_URL + "/services"); WebLink[] links=res.getLinks(); assertEquals("Wrong number of service links",6,links.length); Set links2=new HashSet(); for ( WebLink l : links) { links2.add(l.getURLString()); } assertTrue(links2.contains(CONTEXT_URL + "/services/greeter?wsdl")); assertTrue(links2.contains(CONTEXT_URL + "/services/greeter2?wsdl")); assertTrue(links2.contains("http://cxf.apache.org/MyGreeter?wsdl")); assertEquals("text/html",res.getContentType()); res=client.getResponse(CONTEXT_URL + "/services/"); links=res.getLinks(); links2.clear(); for ( WebLink l : links) { links2.add(l.getURLString()); } assertEquals("Wrong number of service links",6,links.length); assertTrue(links2.contains(CONTEXT_URL + "/services/greeter?wsdl")); assertTrue(links2.contains(CONTEXT_URL + "/services/greeter2?wsdl")); assertTrue(links2.contains("http://cxf.apache.org/MyGreeter?wsdl")); assertEquals("text/html",res.getContentType()); assertNotNull(BusFactory.getDefaultBus(false)); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetWSDLWithXMLBinding() throws Exception { ServletUnitClient client=newClient(); client.setExceptionsThrownOnErrorStatus(true); WebRequest req=new GetMethodQueryWebRequest(CONTEXT_URL + "/services/greeter2?wsdl"); WebResponse res=client.getResponse(req); assertEquals(200,res.getResponseCode()); assertEquals("text/xml",res.getContentType()); Document doc=StaxUtils.read(res.getInputStream()); assertNotNull(doc); addNamespace("http","http://schemas.xmlsoap.org/wsdl/http/"); assertValid("//wsdl:operation[@name='greetMe']",doc); NodeList addresses=assertValid("//http:address/@location",doc); boolean found=true; for (int i=0; i < addresses.getLength(); i++) { String address=addresses.item(i).getLocalName(); if (address.startsWith("http://localhost") && address.endsWith("/services/greeter2")) { found=true; break; } } assertTrue(found); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetWSDLWithMultiplePublishedEndpointUrl() throws Exception { ServletUnitClient client=newClient(); client.setExceptionsThrownOnErrorStatus(true); WebRequest req=new GetMethodQueryWebRequest(CONTEXT_URL + "/services/greeter5?wsdl"); WebResponse res=client.getResponse(req); assertEquals(200,res.getResponseCode()); assertEquals("text/xml",res.getContentType()); Document doc=StaxUtils.read(res.getInputStream()); assertNotNull(doc); WSDLReader wsdlReader=WSDLFactory.newInstance().newWSDLReader(); wsdlReader.setFeature("javax.wsdl.verbose",false); assertValid("//wsdl:service[@name='SOAPService']/wsdl:port[@name='SoapPort']/wsdlsoap:address[@location='" + "http://cxf.apache.org/publishedEndpointUrl1']",doc); assertValid("//wsdl:service[@name='SOAPService']/wsdl:port[@name='SoapPort1']/wsdlsoap:address[@location='" + "http://cxf.apache.org/publishedEndpointUrl2']",doc); }

Class: org.apache.cxf.systest.servlet.ExternalServicesServletTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testPostInvokeServices() throws Exception { newClient(); WebRequest req=new PostMethodWebRequest(CONTEXT_URL + "/greeter",getClass().getResourceAsStream("GreeterMessage.xml"),"text/xml; charset=UTF-8"); WebResponse response=newClient().getResponse(req); assertEquals("text/xml",response.getContentType()); assertEquals(StandardCharsets.UTF_8.name(),response.getCharacterSet()); Document doc=StaxUtils.read(response.getInputStream()); assertNotNull(doc); addNamespace("h","http://apache.org/hello_world_soap_http/types"); assertValid("/s:Envelope/s:Body",doc); assertValid("//h:sayHiResponse",doc); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testGetServiceList() throws Exception { ServletUnitClient client=newClient(); client.setExceptionsThrownOnErrorStatus(false); WebResponse res=client.getResponse(CONTEXT_URL + "/"); WebLink[] links=res.getLinks(); assertEquals("Wrong number of service links",6,links.length); Set links2=new HashSet(); for ( WebLink l : links) { links2.add(l.getURLString()); } assertTrue(links2.contains(FORCED_BASE_ADDRESS + "/greeter?wsdl")); assertTrue(links2.contains(FORCED_BASE_ADDRESS + "/greeter2?wsdl")); assertEquals("text/html",res.getContentType()); }

Class: org.apache.cxf.systest.servlet.JsFrontEndServletTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testPostInvokeServices() throws Exception { WebRequest req=new PostMethodWebRequest(CONTEXT_URL + "/services/Greeter",getClass().getResourceAsStream("GreeterMessage.xml"),"text/xml; charset=UTF-8"); WebResponse response=newClient().getResponse(req); assertEquals("text/xml",response.getContentType()); Document doc=StaxUtils.read(response.getInputStream()); assertNotNull(doc); addNamespace("h","http://apache.org/hello_world_soap_http/types"); assertValid("/s:Envelope/s:Body",doc); assertValid("//h:sayHiResponse",doc); assertValid("//h:responseType",doc); }

Class: org.apache.cxf.systest.servlet.NoSpringServletClientTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBasicConnection() throws Exception { SOAPService service=new SOAPService(new URL(serviceURL + "Greeter?wsdl")); Greeter greeter=service.getPort(portName,Greeter.class); try { String reply=greeter.greetMe("test"); assertNotNull("no response received from service",reply); assertEquals("Hello test",reply); reply=greeter.sayHi(); assertNotNull("no response received from service",reply); assertEquals("Bonjour",reply); } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

InternalCallVerifier EqualityVerifier 
@Test public void testHelloService() throws Exception { JaxWsProxyFactoryBean cpfb=new JaxWsProxyFactoryBean(); String address=serviceURL + "Hello"; cpfb.setServiceClass(Hello.class); cpfb.setAddress(address); Hello hello=(Hello)cpfb.create(); String reply=hello.sayHi(" Willem"); assertEquals("Get the wrongreply ",reply,"get Willem"); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testGetServiceList() throws Exception { WebConversation client=new WebConversation(); WebResponse res=client.getResponse(serviceURL + "/services"); WebLink[] links=res.getLinks(); Set s=new HashSet(); for ( WebLink l : links) { s.add(l.getURLString()); } assertEquals("There should be 3 links for the service",3,links.length); assertTrue(s.contains(serviceURL + "Greeter?wsdl")); assertTrue(s.contains(serviceURL + "Hello?wsdl")); assertTrue(s.contains(serviceURL + "?wsdl")); assertEquals("text/html",res.getContentType()); }

Class: org.apache.cxf.systest.servlet.SpringAutoPublishServletTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetWSDL() throws Exception { ServletUnitClient client=newClient(); client.setExceptionsThrownOnErrorStatus(true); WebRequest req=new GetMethodQueryWebRequest(CONTEXT_URL + "/services/SOAPService?wsdl"); WebResponse res=client.getResponse(req); assertEquals(200,res.getResponseCode()); assertEquals("text/xml",res.getContentType()); Document doc=StaxUtils.read(res.getInputStream()); assertNotNull(doc); assertValid("//wsdl:operation[@name='greetMe']",doc); assertValid("//wsdlsoap:address[@location='" + CONTEXT_URL + "/services/SOAPService']",doc); req=new GetMethodQueryWebRequest(CONTEXT_URL + "/services/DerivedGreeterService?wsdl"); res=client.getResponse(req); assertEquals(200,res.getResponseCode()); assertEquals("text/xml",res.getContentType()); doc=StaxUtils.read(res.getInputStream()); assertNotNull(doc); assertValid("//wsdl:operation[@name='greetMe']",doc); assertValid("//wsdlsoap:address" + "[@location='http://localhost/mycontext/services/DerivedGreeterService']",doc); }

Class: org.apache.cxf.systest.servlet.SpringServletTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetWSDL() throws Exception { ServletUnitClient client=newClient(); client.setExceptionsThrownOnErrorStatus(true); WebRequest req=new GetMethodQueryWebRequest(CONTEXT_URL + "/services/Greeter?wsdl"); WebResponse res=client.getResponse(req); assertEquals(200,res.getResponseCode()); assertEquals("text/xml",res.getContentType()); Document doc=StaxUtils.read(res.getInputStream()); assertNotNull(doc); assertValid("//wsdl:operation[@name='greetMe']",doc); assertValid("//wsdlsoap:address[@location='" + CONTEXT_URL + "/services/Greeter']",doc); req=new GetMethodQueryWebRequest(CONTEXT_URL + "/services/Greeter2?wsdl"); res=client.getResponse(req); assertEquals(200,res.getResponseCode()); assertEquals("text/xml",res.getContentType()); doc=StaxUtils.read(res.getInputStream()); assertNotNull(doc); assertValid("//wsdl:operation[@name='greetMe']",doc); assertValid("//wsdlsoap:address[@location='http://cxf.apache.org/Greeter']",doc); Endpoint.publish("/services/Greeter3",new org.apache.hello_world_soap_http.GreeterImpl()); req=new GetMethodQueryWebRequest(CONTEXT_URL + "/services/Greeter3?wsdl"); res=client.getResponse(req); assertEquals(200,res.getResponseCode()); assertEquals("text/xml",res.getContentType()); doc=StaxUtils.read(res.getInputStream()); assertNotNull(doc); assertValid("//wsdl:operation[@name='greetMe']",doc); assertValid("//wsdlsoap:address[@location='" + CONTEXT_URL + "/services/Greeter3']",doc); }

Class: org.apache.cxf.systest.soap.SoapActionTest

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testRPCLitSoapActionSpoofing() throws Exception { JaxWsProxyFactoryBean pf=new JaxWsProxyFactoryBean(); pf.setServiceClass(WrappedGreeter.class); pf.setAddress(add15); pf.setBus(bus); WrappedGreeter greeter=(WrappedGreeter)pf.create(); assertEquals("sayHi",greeter.sayHiRequestWrapped("test")); assertEquals("sayHi2",greeter.sayHiRequest2Wrapped("test")); ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY,"true"); ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY,"SAY_HI_2"); try { greeter.sayHiRequestWrapped("test"); fail("Failure expected on spoofing attack"); } catch ( Exception ex) { } ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY,"true"); ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY,"SAY_HI_1"); try { greeter.sayHiRequest2Wrapped("test"); fail("Failure expected on spoofing attack"); } catch ( Exception ex) { } ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY,"true"); ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY,"SAY_HI_UNKNOWN"); try { greeter.sayHiRequestWrapped("test"); fail("Failure expected on spoofing attack"); } catch ( Exception ex) { } }

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testWrappedEncodedSoapActionSpoofing() throws Exception { JaxWsProxyFactoryBean pf=new JaxWsProxyFactoryBean(); pf.setServiceClass(WrappedGreeter.class); pf.setAddress(add17); pf.setBus(bus); WrappedGreeter greeter=(WrappedGreeter)pf.create(); assertEquals("sayHi",greeter.sayHiRequestWrapped("test")); assertEquals("sayHi2",greeter.sayHiRequest2Wrapped("test")); ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY,"true"); ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY,"SAY_HI_2"); try { greeter.sayHiRequestWrapped("test"); fail("Failure expected on spoofing attack"); } catch ( Exception ex) { } ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY,"true"); ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY,"SAY_HI_1"); try { greeter.sayHiRequest2Wrapped("test"); fail("Failure expected on spoofing attack"); } catch ( Exception ex) { } ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY,"true"); ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY,"SAY_HI_UNKNOWN"); try { greeter.sayHiRequestWrapped("test"); fail("Failure expected on spoofing attack"); } catch ( Exception ex) { } }

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testWrappedSoap12ActionSpoofing() throws Exception { JaxWsProxyFactoryBean pf=new JaxWsProxyFactoryBean(); pf.setServiceClass(WrappedGreeter.class); pf.setAddress(add14); SoapBindingConfiguration config=new SoapBindingConfiguration(); config.setVersion(Soap12.getInstance()); pf.setBindingConfig(config); pf.setBus(bus); WrappedGreeter greeter=(WrappedGreeter)pf.create(); assertEquals("sayHi",greeter.sayHiRequestWrapped("test")); assertEquals("sayHi2",greeter.sayHiRequest2Wrapped("test")); ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY,"true"); ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY,"SAY_HI_2"); try { greeter.sayHiRequestWrapped("test"); fail("Failure expected on spoofing attack"); } catch ( Exception ex) { } ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY,"true"); ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY,"SAY_HI_1"); try { greeter.sayHiRequest2Wrapped("test"); fail("Failure expected on spoofing attack"); } catch ( Exception ex) { } ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY,"true"); ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY,"SAY_HI_UNKNOWN"); try { greeter.sayHiRequestWrapped("test"); fail("Failure expected on spoofing attack"); } catch ( Exception ex) { } }

InternalCallVerifier EqualityVerifier 
@Test public void testEndpoint() throws Exception { JaxWsProxyFactoryBean pf=new JaxWsProxyFactoryBean(); pf.setServiceClass(Greeter.class); pf.setAddress(add11); pf.setBus(bus); Greeter greeter=(Greeter)pf.create(); assertEquals("sayHi",greeter.sayHi("test")); assertEquals("sayHi2",greeter.sayHi2("test")); }

InternalCallVerifier EqualityVerifier 
@Test public void testSoap12Endpoint() throws Exception { JaxWsProxyFactoryBean pf=new JaxWsProxyFactoryBean(); pf.setServiceClass(Greeter.class); pf.setAddress(add12); SoapBindingConfiguration config=new SoapBindingConfiguration(); config.setVersion(Soap12.getInstance()); pf.setBindingConfig(config); pf.setBus(bus); Greeter greeter=(Greeter)pf.create(); assertEquals("sayHi",greeter.sayHi("test")); assertEquals("sayHi2",greeter.sayHi2("test")); }

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testBareSoapActionSpoofing() throws Exception { JaxWsProxyFactoryBean pf=new JaxWsProxyFactoryBean(); pf.setServiceClass(Greeter.class); pf.setAddress(add11); pf.setBus(bus); Greeter greeter=(Greeter)pf.create(); assertEquals("sayHi",greeter.sayHi("test")); assertEquals("sayHi2",greeter.sayHi2("test")); ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY,"true"); ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY,"SAY_HI_2"); try { greeter.sayHi("test"); fail("Failure expected on spoofing attack"); } catch ( Exception ex) { } ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY,"true"); ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY,"SAY_HI_1"); try { greeter.sayHi2("test"); fail("Failure expected on spoofing attack"); } catch ( Exception ex) { } ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY,"true"); ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY,"SAY_HI_UNKNOWN"); try { greeter.sayHi("test"); fail("Failure expected on spoofing attack"); } catch ( Exception ex) { } }

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testRPCEncodedSoapActionSpoofing() throws Exception { JaxWsProxyFactoryBean pf=new JaxWsProxyFactoryBean(); pf.setServiceClass(WrappedGreeter.class); pf.setAddress(add16); pf.setBus(bus); WrappedGreeter greeter=(WrappedGreeter)pf.create(); assertEquals("sayHi",greeter.sayHiRequestWrapped("test")); assertEquals("sayHi2",greeter.sayHiRequest2Wrapped("test")); ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY,"true"); ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY,"SAY_HI_2"); try { greeter.sayHiRequestWrapped("test"); fail("Failure expected on spoofing attack"); } catch ( Exception ex) { } ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY,"true"); ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY,"SAY_HI_1"); try { greeter.sayHiRequest2Wrapped("test"); fail("Failure expected on spoofing attack"); } catch ( Exception ex) { } ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY,"true"); ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY,"SAY_HI_UNKNOWN"); try { greeter.sayHiRequestWrapped("test"); fail("Failure expected on spoofing attack"); } catch ( Exception ex) { } }

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testWrappedSoapActionSpoofing() throws Exception { JaxWsProxyFactoryBean pf=new JaxWsProxyFactoryBean(); pf.setServiceClass(WrappedGreeter.class); pf.setAddress(add13); pf.setBus(bus); WrappedGreeter greeter=(WrappedGreeter)pf.create(); assertEquals("sayHi",greeter.sayHiRequestWrapped("test")); assertEquals("sayHi2",greeter.sayHiRequest2Wrapped("test")); ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY,"true"); ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY,"SAY_HI_2"); try { greeter.sayHiRequestWrapped("test"); fail("Failure expected on spoofing attack"); } catch ( Exception ex) { } ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY,"true"); ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY,"SAY_HI_1"); try { greeter.sayHiRequest2Wrapped("test"); fail("Failure expected on spoofing attack"); } catch ( Exception ex) { } ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY,"true"); ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY,"SAY_HI_UNKNOWN"); try { greeter.sayHiRequestWrapped("test"); fail("Failure expected on spoofing attack"); } catch ( Exception ex) { } }

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testBareSoap12ActionSpoofing() throws Exception { JaxWsProxyFactoryBean pf=new JaxWsProxyFactoryBean(); pf.setServiceClass(Greeter.class); pf.setAddress(add12); SoapBindingConfiguration config=new SoapBindingConfiguration(); config.setVersion(Soap12.getInstance()); pf.setBindingConfig(config); pf.setBus(bus); Greeter greeter=(Greeter)pf.create(); assertEquals("sayHi",greeter.sayHi("test")); assertEquals("sayHi2",greeter.sayHi2("test")); ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY,"true"); ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY,"SAY_HI_2"); try { greeter.sayHi("test"); fail("Failure expected on spoofing attack"); } catch ( Exception ex) { } ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY,"true"); ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY,"SAY_HI_1"); try { greeter.sayHi2("test"); fail("Failure expected on spoofing attack"); } catch ( Exception ex) { } ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY,"true"); ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY,"SAY_HI_UNKNOWN"); try { greeter.sayHi("test"); fail("Failure expected on spoofing attack"); } catch ( Exception ex) { } }

Class: org.apache.cxf.systest.soap12.Soap12ClientServerTest

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testPingMeFault() throws Exception { Greeter greeter=getGreeter(); try { greeter.pingMe(); fail("Should throw Exception!"); } catch ( PingMeFault ex) { FaultDetail detail=ex.getFaultInfo(); assertEquals((short)2,detail.getMajor()); assertEquals((short)1,detail.getMinor()); assertEquals("PingMeFault raised by server",ex.getMessage()); } }

IterativeVerifier InternalCallVerifier EqualityVerifier 
@Test public void testBasicConnection() throws Exception { Greeter greeter=getGreeter(); for (int i=0; i < 5; i++) { String echo=greeter.sayHi(); assertEquals("Bonjour",echo); } }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSayHiSoap12ToSoap11() throws Exception { HttpURLConnection httpConnection=getHttpConnection("http://localhost:" + PORT + "/SoapContext/Soap11Port/sayHi"); httpConnection.setDoOutput(true); InputStream reqin=Soap12ClientServerTest.class.getResourceAsStream("sayHiSOAP12Req.xml"); assertNotNull("could not load test data",reqin); httpConnection.setRequestMethod("POST"); httpConnection.addRequestProperty("Content-Type","text/xml;charset=utf-8"); OutputStream reqout=httpConnection.getOutputStream(); IOUtils.copy(reqin,reqout); reqout.close(); assertEquals(500,httpConnection.getResponseCode()); InputStream respin=httpConnection.getErrorStream(); assertNotNull(respin); assertEquals("text/xml;charset=utf-8",stripSpaces(httpConnection.getContentType().toLowerCase())); Document doc=StaxUtils.read(respin); assertNotNull(doc); Map ns=new HashMap(); ns.put("soap11",Soap11.SOAP_NAMESPACE); XPathUtils xu=new XPathUtils(ns); Node fault=(Node)xu.getValue("/soap11:Envelope/soap11:Body/soap11:Fault",doc,XPathConstants.NODE); assertNotNull(fault); String codev=(String)xu.getValue("//faultcode/text()",fault,XPathConstants.STRING); assertNotNull(codev); assertTrue("VersionMismatch expected",codev.endsWith("VersionMismatch")); }

Class: org.apache.cxf.systest.soap_udp.SoapUDPTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSOAPUDP(){ BusFactory.setThreadDefaultBus(staticBus); Service service=Service.create(serviceName); service.addPort(localPortName,"http://schemas.xmlsoap.org/soap/","soap.udp://localhost:" + PORT); Greeter greeter=service.getPort(localPortName,Greeter.class); String reply=greeter.greetMe("test"); assertEquals("Hello test",reply); reply=greeter.sayHi(); assertNotNull("no response received from service",reply); assertEquals("Bonjour",reply); }

Class: org.apache.cxf.systest.soapfault.details.Soap11ClientServerTest

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testPingMeFault() throws Exception { Greeter greeter=getGreeter(); try { greeter.pingMe(); fail("Should throw Exception!"); } catch ( PingMeFault ex) { FaultDetail detail=ex.getFaultInfo(); assertEquals((short)2,detail.getMajor()); assertEquals((short)1,detail.getMinor()); assertEquals("PingMeFault raised by server",ex.getMessage()); StackTraceElement[] element=ex.getStackTrace(); assertEquals("org.apache.cxf.systest.soapfault.details.GreeterImpl11",element[0].getClassName()); } }

APIUtilityVerifier UtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testNewLineInExceptionMessage() throws Exception { Greeter greeter=getGreeter(); try { greeter.greetMe("newline"); fail("Should throw Exception!"); } catch ( SOAPFaultException ex) { assertEquals("greetMeFault Caused by: Get a wrong name ",ex.getMessage()); StackTraceElement[] elements=ex.getCause().getStackTrace(); assertEquals("org.apache.cxf.systest.soapfault.details.GreeterImpl11",elements[0].getClassName()); assertTrue(ex.getCause().getCause().getMessage().endsWith("Test \n cause.")); } }

APIUtilityVerifier UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testFaultMessage() throws Exception { Greeter greeter=getGreeter(); try { greeter.sayHi(); fail("Should throw Exception!"); } catch ( SOAPFaultException ex) { assertEquals("sayHiFault Caused by: Get a wrong name ",ex.getMessage()); StackTraceElement[] elements=ex.getCause().getStackTrace(); assertEquals("org.apache.cxf.systest.soapfault.details.GreeterImpl11",elements[0].getClassName()); } try { greeter.greetMe("Anya"); fail("Should throw Exception!"); } catch ( SOAPFaultException ex) { assertEquals(NullPointerException.class.getName(),ex.getMessage()); } try { greeter.greetMe("Banya"); fail("Should throw Exception!"); } catch ( SOAPFaultException ex) { assertEquals("Get a wrong name for greetMe",ex.getMessage()); } try { greeter.greetMe("Canya"); fail("Should throw Exception!"); } catch ( SOAPFaultException ex) { assertEquals("unexpected null",ex.getMessage()); } try { greeter.greetMe("Danya"); fail("Should throw Exception!"); } catch ( SOAPFaultException ex) { assertEquals("greetMeFault Caused by: Get a wrong name greetMe",ex.getMessage()); } try { greeter.greetMe("Eanna"); fail("Should throw Exception!"); } catch ( SOAPFaultException ex) { assertEquals("invalid",ex.getMessage()); } }

Class: org.apache.cxf.systest.soapfault.details.Soap12ClientServerTest

APIUtilityVerifier UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testFaultMessage() throws Exception { Greeter greeter=getGreeter(); try { greeter.sayHi(); fail("Should throw Exception!"); } catch ( SOAPFaultException ex) { assertEquals("sayHiFault Caused by: Get a wrong name ",ex.getMessage()); StackTraceElement[] element=ex.getCause().getStackTrace(); assertEquals("org.apache.cxf.systest.soapfault.details.GreeterImpl12",element[0].getClassName()); } }

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testPingMeFault() throws Exception { Greeter greeter=getGreeter(); try { greeter.pingMe(); fail("Should throw Exception!"); } catch ( PingMeFault ex) { FaultDetail detail=ex.getFaultInfo(); assertEquals((short)2,detail.getMajor()); assertEquals((short)1,detail.getMinor()); assertEquals("PingMeFault raised by server",ex.getMessage()); StackTraceElement[] element=ex.getStackTrace(); assertEquals("org.apache.cxf.systest.soapfault.details.GreeterImpl12",element[0].getClassName()); } }

Class: org.apache.cxf.systest.soapheader.HeaderClientServerTest

InternalCallVerifier EqualityVerifier 
@Test public void testBasicConnection() throws Exception { Pizza port=getPort(); updateAddressPort(port,PORT); OrderPizzaType req=new OrderPizzaType(); ToppingsListType t=new ToppingsListType(); t.getTopping().add("test"); req.setToppings(t); CallerIDHeaderType header=new CallerIDHeaderType(); header.setName("mao"); header.setPhoneNumber("108"); OrderPizzaResponseType res=port.orderPizza(req,header); assertEquals(208,res.getMinutesUntilReady()); }

InternalCallVerifier EqualityVerifier 
@Test public void testBasicConnectionNoHeader() throws Exception { PizzaNoHeader port=getPortNoHeader(); updateAddressPort(port,PORT); OrderPizzaType req=new OrderPizzaType(); ToppingsListType t=new ToppingsListType(); t.getTopping().add("NoHeader!"); t.getTopping().add("test"); req.setToppings(t); OrderPizzaResponseType res=port.orderPizza(req); assertEquals(100,res.getMinutesUntilReady()); }

Class: org.apache.cxf.systest.source.ClientServerSourceTest

UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCallFromClient() throws Exception { SpringBusFactory factory=new SpringBusFactory(); Bus bus=factory.createBus("org/apache/cxf/systest/source/cxf.xml"); BusFactory.setDefaultBus(bus); URL wsdl=this.getClass().getResource("/wsdl_systest_databinding/source/hello_world.wsdl"); assertNotNull("We should have found the WSDL here. ",wsdl); SOAPService ss=new SOAPService(wsdl,SERVICE_NAME); Greeter port=ss.getSoapPort(); updateAddressPort(port,WSDL_PORT); ClientProxy.getClient(port).getInInterceptors().add(new LoggingInInterceptor()); ClientProxy.getClient(port).getOutInterceptors().add(new LoggingOutInterceptor()); Document doc=DOMUtils.newDocument(); doc.appendChild(doc.createElementNS("http://apache.org/hello_world_soap_http_source/source/types","ns1:sayHi")); DOMSource ds=new DOMSource(doc); DOMSource resp=port.sayHi(ds); assertEquals("We should get the right response","Bonjour",DOMUtils.getContent(getElement(resp.getNode().getFirstChild().getFirstChild()))); doc=DOMUtils.newDocument(); Element el=doc.createElementNS("http://apache.org/hello_world_soap_http_source/source/types","ns1:greetMe"); Element el2=doc.createElementNS("http://apache.org/hello_world_soap_http_source/source/types","ns1:requestType"); el2.appendChild(doc.createTextNode("Willem")); el.appendChild(el2); doc.appendChild(el); ds=new DOMSource(doc); resp=port.greetMe(ds); assertEquals("We should get the right response","Hello Willem",DOMUtils.getContent(DOMUtils.getFirstElement(getElement(resp.getNode())))); try { doc=DOMUtils.newDocument(); el=doc.createElementNS("http://apache.org/hello_world_soap_http_source/source/types","ns1:greetMe"); el2=doc.createElementNS("http://apache.org/hello_world_soap_http_source/source/types","ns1:requestType"); el2.appendChild(doc.createTextNode("fault")); el.appendChild(el2); doc.appendChild(el); ds=new DOMSource(doc); port.greetMe(ds); fail("Should have been a fault"); } catch ( GreetMeFault ex) { assertEquals("Some fault detail",DOMUtils.getContent(getElement(ex.getFaultInfo().getNode()))); } }

Class: org.apache.cxf.systest.stax_transform_feature.StaxTransformFeatureTest

EqualityVerifier 
@Test public void testTransformWithLogging() throws Exception { SpringBusFactory bf=new SpringBusFactory(); Bus bus=bf.createBus(); BusFactory.setDefaultBus(bus); TestLoggingInInterceptor logIn=new TestLoggingInInterceptor(); bus.getInInterceptors().add(logIn); TestLoggingOutInterceptor logOut=new TestLoggingOutInterceptor(); bus.getOutInterceptors().add(logOut); bus.getOutFaultInterceptors().add(logOut); TransformInInterceptor transIn=new TransformInInterceptor(); Map inElements=new HashMap(); inElements.put("{http://cxf.apache.org/greeter_control/types}noFaultDetail","{http://cxf.apache.org/greeter_control/types}faultDetail"); bus.getInInterceptors().add(transIn); TransformOutInterceptor transOut=new TransformOutInterceptor(); Map outElements=new HashMap(); outElements.put("{http://cxf.apache.org/greeter_control/types}pingMe","{http://cxf.apache.org/greeter_control/types}dontPingMe"); transOut.setOutTransformElements(outElements); bus.getOutInterceptors().add(transOut); bus.getOutFaultInterceptors().add(transOut); GreeterService gs=new GreeterService(); greeter=gs.getGreeterPort(); updateAddressPort(greeter,PORT); LOG.fine("Created greeter client."); greeter.pingMe(); verifyPayload(logOut.getMessage(),"dontPingMe"); verifyPayload(logIn.getMessage(),"pingMeResponse"); verifyPayload(serverlogIn.getMessage(),"dontPingMe"); verifyPayload(serverlogOut.getMessage(),"pingMeResponse"); serverlogOut.cleaerMessage(); serverlogIn.cleaerMessage(); logOut.cleaerMessage(); logIn.cleaerMessage(); try { greeter.pingMe(); } catch ( Exception e) { assertEquals("Pings succeed only every other time.",e.getMessage()); } verifyPayload(logOut.getMessage(),"dontPingMe"); verifyPayload(logIn.getMessage(),"noFaultDetail"); verifyPayload(serverlogIn.getMessage(),"dontPingMe"); verifyPayload(serverlogOut.getMessage(),"noFaultDetail"); greeter.pingMe(); serverlogOut.cleaerMessage(); serverlogIn.cleaerMessage(); logOut.cleaerMessage(); logIn.cleaerMessage(); transOut.setSkipOnFault(true); servertransOut.setSkipOnFault(true); try { greeter.pingMe(); } catch ( Exception e) { assertEquals("Pings succeed only every other time.",e.getMessage()); } verifyPayload(logOut.getMessage(),"dontPingMe"); verifyPayload(logIn.getMessage(),"faultDetail"); verifyPayload(serverlogIn.getMessage(),"dontPingMe"); verifyPayload(serverlogOut.getMessage(),"faultDetail"); bus.shutdown(true); }

Class: org.apache.cxf.systest.stringarray.StringArrayTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testStringArrayList() throws Exception { SpringBusFactory factory=new SpringBusFactory(); Bus bus=factory.createBus(); BusFactory.setDefaultBus(bus); setBus(bus); StringWriter swin=new java.io.StringWriter(); java.io.PrintWriter pwin=new java.io.PrintWriter(swin); LoggingInInterceptor logIn=new LoggingInInterceptor(pwin); StringWriter swout=new java.io.StringWriter(); java.io.PrintWriter pwout=new java.io.PrintWriter(swout); LoggingOutInterceptor logOut=new LoggingOutInterceptor(pwout); getBus().getInInterceptors().add(logIn); getBus().getOutInterceptors().add(logOut); SOAPServiceRPCLit service=new SOAPServiceRPCLit(); StringListTest port=service.getSoapPortRPCLit(); updateAddressPort(port,PORT); String[] strs=new String[]{"org","apache","cxf"}; String[] res=port.stringListTest(strs); assertArrayEquals(strs,res); assertTrue("Request message is not marshalled correctly and @XmlList does not take effect",swout.toString().indexOf("org apache cxf") > -1); assertTrue("Response message is not marshalled correctly and @XmlList does not take effect",swin.toString().indexOf("org apache cxf") > -1); }

Class: org.apache.cxf.systest.swa.ClientServerSwaTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier PublicFieldVerifier HybridVerifier 
@Test public void testSwaNoMimeCodeGen() throws Exception { org.apache.cxf.swa_nomime.SwAService service=new org.apache.cxf.swa_nomime.SwAService(); org.apache.cxf.swa_nomime.SwAServiceInterface port=service.getSwAServiceHttpPort(); setAddress(port,"http://localhost:" + serverPort + "/swa-nomime"); Holder textHolder=new Holder("Hi"); Holder data=new Holder("foobar".getBytes()); port.echoData(textHolder,data); String string=IOUtils.newStringFromBytes(data.value); assertEquals("testfoobar",string); assertEquals("Hi",textHolder.value); URL url1=this.getClass().getResource("resources/attach.text"); URL url2=this.getClass().getResource("resources/attach.html"); URL url3=this.getClass().getResource("resources/attach.xml"); URL url4=this.getClass().getResource("resources/attach.jpeg1"); URL url5=this.getClass().getResource("resources/attach.jpeg2"); Holder attach1=new Holder(IOUtils.toString(url1.openStream())); Holder attach2=new Holder(IOUtils.toString(url2.openStream())); Holder attach3=new Holder(IOUtils.toString(url3.openStream())); Holder attach4=new Holder(IOUtils.readBytesFromStream(url4.openStream())); Holder attach5=new Holder(IOUtils.readBytesFromStream(url5.openStream())); org.apache.cxf.swa_nomime.types.VoidRequest request=new org.apache.cxf.swa_nomime.types.VoidRequest(); org.apache.cxf.swa_nomime.types.OutputResponseAll response=port.echoAllAttachmentTypes(request,attach1,attach2,attach3,attach4,attach5); assertNotNull(response); }

APIUtilityVerifier EqualityVerifier 
@Test public void testSwaWithHeaders() throws Exception { SwAService service=new SwAService(); SwAServiceInterface port=service.getSwAServiceHttpPort(); setAddress(port,"http://localhost:" + serverPort + "/swa"); Holder textHolder=new Holder(); Holder headerHolder=new Holder(); Holder data=new Holder(); ByteArrayDataSource source=new ByteArrayDataSource("foobar".getBytes(),"application/octet-stream"); DataHandler handler=new DataHandler(source); data.value=handler; textHolder.value="Hi"; headerHolder.value="Header"; port.echoDataWithHeader(textHolder,data,headerHolder); InputStream bis=null; bis=data.value.getDataSource().getInputStream(); byte b[]=new byte[10]; bis.read(b,0,10); String string=IOUtils.newStringFromBytes(b); assertEquals("testfoobar",string); assertEquals("Hi",textHolder.value); assertEquals("Header",headerHolder.value); }

APIUtilityVerifier EqualityVerifier 
@Test public void testSwa() throws Exception { SwAService service=new SwAService(); SwAServiceInterface port=service.getSwAServiceHttpPort(); setAddress(port,"http://localhost:" + serverPort + "/swa"); Holder textHolder=new Holder(); Holder data=new Holder(); ByteArrayDataSource source=new ByteArrayDataSource("foobar".getBytes(),"application/octet-stream"); DataHandler handler=new DataHandler(source); data.value=handler; textHolder.value="Hi"; port.echoData(textHolder,data); InputStream bis=null; bis=data.value.getDataSource().getInputStream(); byte b[]=new byte[10]; bis.read(b,0,10); String string=IOUtils.newStringFromBytes(b); assertEquals("testfoobar",string); assertEquals("Hi",textHolder.value); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testSwaTypesWithDispatchAPI() throws Exception { URL url1=this.getClass().getResource("resources/attach.text"); URL url2=this.getClass().getResource("resources/attach.html"); URL url3=this.getClass().getResource("resources/attach.xml"); URL url4=this.getClass().getResource("resources/attach.jpeg1"); URL url5=this.getClass().getResource("resources/attach.jpeg2"); byte[] bytes=IOUtils.readBytesFromStream(url1.openStream()); byte[] bigBytes=new byte[bytes.length * 50]; for (int x=0; x < 50; x++) { System.arraycopy(bytes,0,bigBytes,x * bytes.length,bytes.length); } DataHandler dh1=new DataHandler(new ByteArrayDataSource(bigBytes,"text/plain")); DataHandler dh2=new DataHandler(url2); DataHandler dh3=new DataHandler(url3); DataHandler dh4=new DataHandler(url4); DataHandler dh5=new DataHandler(url5); SwAService service=new SwAService(); Dispatch disp=service.createDispatch(SwAService.SwAServiceHttpPort,SOAPMessage.class,Service.Mode.MESSAGE); setAddress(disp,"http://localhost:" + serverPort + "/swa"); SOAPMessage msg=MessageFactory.newInstance().createMessage(); SOAPBody body=msg.getSOAPPart().getEnvelope().getBody(); body.addBodyElement(new QName("http://cxf.apache.org/swa/types","VoidRequest")); AttachmentPart att=msg.createAttachmentPart(dh1); att.setContentId(""); msg.addAttachmentPart(att); att=msg.createAttachmentPart(dh2); att.setContentId(""); msg.addAttachmentPart(att); att=msg.createAttachmentPart(dh3); att.setContentId(""); msg.addAttachmentPart(att); att=msg.createAttachmentPart(dh4); att.setContentId(""); msg.addAttachmentPart(att); att=msg.createAttachmentPart(dh5); att.setContentId(""); msg.addAttachmentPart(att); msg=disp.invoke(msg); assertEquals(5,msg.countAttachments()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSwaTypes() throws Exception { SwAService service=new SwAService(); SwAServiceInterface port=service.getSwAServiceHttpPort(); setAddress(port,"http://localhost:" + serverPort + "/swa"); URL url1=this.getClass().getResource("resources/attach.text"); URL url2=this.getClass().getResource("resources/attach.html"); URL url3=this.getClass().getResource("resources/attach.xml"); URL url4=this.getClass().getResource("resources/attach.jpeg1"); URL url5=this.getClass().getResource("resources/attach.jpeg2"); DataHandler dh1=new DataHandler(url1); DataHandler dh2=new DataHandler(url2); DataHandler dh3=new DataHandler(url3); Holder attach1=new Holder(); attach1.value=dh1; Holder attach2=new Holder(); attach2.value=dh2; Holder attach3=new Holder(); attach3.value=new StreamSource(dh3.getInputStream()); Holder attach4=new Holder(); Holder attach5=new Holder(); attach4.value=ImageIO.read(url4); attach5.value=ImageIO.read(url5); VoidRequest request=new VoidRequest(); OutputResponseAll response=port.echoAllAttachmentTypes(request,attach1,attach2,attach3,attach4,attach5); assertNotNull(response); Map map=CastUtils.cast((Map)((BindingProvider)port).getResponseContext().get(MessageContext.INBOUND_MESSAGE_ATTACHMENTS)); assertNotNull(map); assertEquals(5,map.size()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testSwaDataStruct() throws Exception { SwAService service=new SwAService(); SwAServiceInterface port=service.getSwAServiceHttpPort(); setAddress(port,"http://localhost:" + serverPort + "/swa"); Holder structHolder=new Holder(); ByteArrayDataSource source=new ByteArrayDataSource("foobar".getBytes(),"application/octet-stream"); DataHandler handler=new DataHandler(source); DataStruct struct=new DataStruct(); struct.setDataRef(handler); structHolder.value=struct; port.echoDataRef(structHolder); handler=structHolder.value.getDataRef(); InputStream bis=null; bis=handler.getDataSource().getInputStream(); byte b[]=new byte[10]; bis.read(b,0,10); String string=IOUtils.newStringFromBytes(b); assertEquals("testfoobar",string); }

Class: org.apache.cxf.systest.type_substitution.AppleFindClientServerTest

APIUtilityVerifier EqualityVerifier 
@Test public void testBasicConnection() throws Exception { QName serviceName=new QName("http://type_substitution.systest.cxf.apache.org/","AppleFinder"); QName portName=new QName("http://type_substitution.systest.cxf.apache.org/","AppleFinderPort"); Service service=Service.create(serviceName); String endpointAddress="http://localhost:" + PORT + "/appleFind"; service.addPort(portName,SOAPBinding.SOAP11HTTP_BINDING,endpointAddress); AppleFinder finder=service.getPort(AppleFinder.class); assertEquals(2,finder.getApple("Fuji").size()); }

Class: org.apache.cxf.systest.type_substitution.TypeSubClientServerTest

APIUtilityVerifier BranchVerifier UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBasicConnection() throws Exception { CarDealer dealer=getCardealer(); List cars=dealer.getSedans("porsche"); assertEquals(2,cars.size()); Porsche car=(Porsche)cars.get(0); assertNotNull(car); if (car != null && "Porsche".equals(car.getMake()) && "Boxster".equals(car.getModel()) && "1998".equals(car.getYear()) && "white".equals(car.getColor())) { } else { fail("Get the wrong car!"); } Porsche oldCar=new Porsche(); oldCar.setMake("Porsche"); oldCar.setColor("white"); oldCar.setModel("GT2000"); oldCar.setYear("2000"); Porsche newCar=(Porsche)dealer.tradeIn(oldCar); assertNotNull(newCar); if (newCar != null && "Porsche".equals(newCar.getMake()) && "911GT3".equals(newCar.getModel()) && "2007".equals(newCar.getYear()) && "black".equals(newCar.getColor())) { } else { fail("Get the wrong car!"); } }

Class: org.apache.cxf.systest.type_test.AbstractTypeTestClient

BranchVerifier UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testSimpleRestriction4() throws Exception { if (!shouldRunTest("SimpleRestriction4")) { return; } String x="x"; String yOrig="y"; Holder y=new Holder(yOrig); Holder z=new Holder(); String ret; if (testDocLiteral) { ret=docClient.testSimpleRestriction4(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testSimpleRestriction4(x,y,z); } else { ret=rpcClient.testSimpleRestriction4(x,y,z); } if (!perfTestOnly) { assertEquals("testSimpleRestriction4(): Incorrect value for inout param",x,y.value); assertEquals("testSimpleRestriction4(): Incorrect value for out param",yOrig,z.value); assertEquals("testSimpleRestriction4(): Incorrect return value",x,ret); } if (testDocLiteral || testXMLBinding) { x="str"; y=new Holder(yOrig); z=new Holder(); try { ret=testDocLiteral ? docClient.testSimpleRestriction4(x,y,z) : xmlClient.testSimpleRestriction4(x,y,z); fail("x parameter minLength=5 restriction is violated."); } catch ( Exception ex) { } } }

IterativeVerifier BranchVerifier InternalCallVerifier EqualityVerifier 
@Test public void testInteger() throws Exception { if (!shouldRunTest("Integer")) { return; } BigInteger valueSets[][]={{new BigInteger("-1234567890"),new BigInteger("1234567890")},{new BigInteger("-" + String.valueOf(Long.MAX_VALUE * Long.MAX_VALUE)),new BigInteger(String.valueOf(Long.MAX_VALUE * Long.MAX_VALUE))}}; for (int i=0; i < valueSets.length; i++) { BigInteger x=valueSets[i][0]; Holder yOrig=new Holder(valueSets[i][1]); Holder y=new Holder(valueSets[i][1]); Holder z=new Holder(); BigInteger ret; if (testDocLiteral) { ret=docClient.testInteger(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testInteger(x,y,z); } else { ret=rpcClient.testInteger(x,y,z); } if (!perfTestOnly) { assertEquals("testInteger(): Incorrect value for inout param",x,y.value); assertEquals("testInteger(): Incorrect value for out param",yOrig.value,z.value); assertEquals("testInteger(): Incorrect return value",x,ret); } } }

IterativeVerifier BranchVerifier InternalCallVerifier EqualityVerifier 
@Test public void testQName() throws Exception { if (!shouldRunTest("QName")) { return; } String valueSets[][]={{"NoNamespaceService",""},{"HelloWorldService","http://www.iona.com/services"},{I18NStrings.JAP_SIMPLE_STRING,"http://www.iona.com/iona"},{"MyService","http://www.iona.com/iona"}}; for (int i=0; i < valueSets.length; i++) { QName x=new QName(valueSets[i][1],valueSets[i][0]); QName yOrig=new QName("http://www.iona.com/inoutqname","InOutQName"); Holder y=new Holder(yOrig); Holder z=new Holder(); QName ret; if (testDocLiteral) { ret=docClient.testQName(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testQName(x,y,z); } else { ret=rpcClient.testQName(x,y,z); } if (!perfTestOnly) { assertEquals("testQName(): Incorrect value for inout param",x,y.value); assertEquals("testQName(): Incorrect value for out param",yOrig,z.value); assertEquals("testQName(): Incorrect return value",x,ret); } } }

IterativeVerifier BranchVerifier InternalCallVerifier EqualityVerifier 
@Test public void testUnsignedByte() throws Exception { if (!shouldRunTest("UnsignedByte")) { return; } short valueSets[][]={{0,1},{1,0},{0,Byte.MAX_VALUE * 2 + 1}}; for (int i=0; i < valueSets.length; i++) { short x=valueSets[i][0]; Holder yOrig=new Holder(valueSets[i][1]); Holder y=new Holder(valueSets[i][1]); Holder z=new Holder(); short ret; if (testDocLiteral) { ret=docClient.testUnsignedByte(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testUnsignedByte(x,y,z); } else { ret=rpcClient.testUnsignedByte(x,y,z); } if (!perfTestOnly) { assertEquals("testUnsignedByte(): Incorrect value for inout param",Short.valueOf(x),y.value); assertEquals("testUnsignedByte(): Incorrect value for out param",yOrig.value,z.value); assertEquals("testUnsignedByte(): Incorrect return value",x,ret); } } }

IterativeVerifier BranchVerifier InternalCallVerifier EqualityVerifier 
@Test public void testPositiveInteger() throws Exception { if (!shouldRunTest("PositiveInteger")) { return; } BigInteger valueSets[][]={{new BigInteger("1"),new BigInteger("1234567890")},{new BigInteger(String.valueOf(Integer.MAX_VALUE * Integer.MAX_VALUE)),new BigInteger(String.valueOf(Long.MAX_VALUE * Long.MAX_VALUE))}}; for (int i=0; i < valueSets.length; i++) { BigInteger x=valueSets[i][0]; Holder yOrig=new Holder(valueSets[i][1]); Holder y=new Holder(valueSets[i][1]); Holder z=new Holder(); BigInteger ret; if (testDocLiteral) { ret=docClient.testPositiveInteger(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testPositiveInteger(x,y,z); } else { ret=rpcClient.testPositiveInteger(x,y,z); } if (!perfTestOnly) { assertEquals("testPositiveInteger(): Incorrect value for inout param",x,y.value); assertEquals("testPositiveInteger(): Incorrect value for out param",yOrig.value,z.value); assertEquals("testPositiveInteger(): Incorrect return value",x,ret); } } }

BranchVerifier UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testSimpleRestriction5() throws Exception { if (!shouldRunTest("SimpleRestriction5")) { return; } String x="str_x"; String yOrig="string_yyy"; Holder y=new Holder(yOrig); Holder z=new Holder(); String ret; if (testDocLiteral) { ret=docClient.testSimpleRestriction5(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testSimpleRestriction5(x,y,z); } else { ret=rpcClient.testSimpleRestriction5(x,y,z); } if (!perfTestOnly) { assertEquals("testSimpleRestriction5(): Incorrect value for inout param",x,y.value); assertEquals("testSimpleRestriction5(): Incorrect value for out param",yOrig,z.value); assertEquals("testSimpleRestriction5(): Incorrect return value",x,ret); } if (testDocLiteral || testXMLBinding) { x="str"; y=new Holder(yOrig); z=new Holder(); try { ret=docClient.testSimpleRestriction5(x,y,z); fail("maxLength=10 && minLength=5 restriction is violated."); } catch ( Exception ex) { } x="string_x"; yOrig="string_yyyyyy"; y=new Holder(yOrig); z=new Holder(); try { ret=testDocLiteral ? docClient.testSimpleRestriction5(x,y,z) : xmlClient.testSimpleRestriction5(x,y,z); fail("maxLength=10 && minLength=5 restriction is violated."); } catch ( Exception ex) { } } }

IterativeVerifier BranchVerifier InternalCallVerifier EqualityVerifier 
@Test public void testColourEnum() throws Exception { if (!shouldRunTest("ColourEnum")) { return; } String[] xx={"RED","GREEN","BLUE"}; String[] yy={"GREEN","BLUE","RED"}; Holder z=new Holder(); for (int i=0; i < 3; i++) { ColourEnum x=ColourEnum.fromValue(xx[i]); ColourEnum yOrig=ColourEnum.fromValue(yy[i]); Holder y=new Holder(yOrig); ColourEnum ret; if (testDocLiteral) { ret=docClient.testColourEnum(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testColourEnum(x,y,z); } else { ret=rpcClient.testColourEnum(x,y,z); } if (!perfTestOnly) { assertEquals("testColourEnum(): Incorrect value for inout param",x.value(),y.value.value()); assertEquals("testColourEnum(): Incorrect value for out param",yOrig.value(),z.value.value()); assertEquals("testColourEnum(): Incorrect return value",x.value(),ret.value()); } } }

BranchVerifier UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testSimpleRestriction2() throws Exception { if (!shouldRunTest("SimpleRestriction2")) { return; } String x="str_x"; String yOrig="string_yyy"; Holder y=new Holder(yOrig); Holder z=new Holder(); String ret; if (testDocLiteral) { ret=docClient.testSimpleRestriction2(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testSimpleRestriction2(x,y,z); } else { ret=rpcClient.testSimpleRestriction2(x,y,z); } if (!perfTestOnly) { assertEquals("testSimpleRestriction2(): Incorrect value for inout param",x,y.value); assertEquals("testSimpleRestriction2(): Incorrect value for out param",yOrig,z.value); assertEquals("testSimpleRestriction2(): Incorrect return value",x,ret); } if (testDocLiteral || testXMLBinding) { x="str"; y=new Holder(yOrig); z=new Holder(); try { ret=testDocLiteral ? docClient.testSimpleRestriction2(x,y,z) : xmlClient.testSimpleRestriction2(x,y,z); fail("minLength=5 restriction is violated."); } catch ( Exception ex) { } } }

IterativeVerifier BranchVerifier InternalCallVerifier EqualityVerifier 
@Test public void testUnsignedShort() throws Exception { if (!shouldRunTest("UnsignedShort")) { return; } int valueSets[][]={{0,1},{1,0},{0,Short.MAX_VALUE * 2 + 1}}; for (int i=0; i < valueSets.length; i++) { int x=valueSets[i][0]; Holder yOrig=new Holder(valueSets[i][1]); Holder y=new Holder(valueSets[i][1]); Holder z=new Holder(); int ret; if (testDocLiteral) { ret=docClient.testUnsignedShort(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testUnsignedShort(x,y,z); } else { ret=rpcClient.testUnsignedShort(x,y,z); } if (!perfTestOnly) { assertEquals("testUnsignedShort(): Incorrect value for inout param",Integer.valueOf(x),y.value); assertEquals("testUnsignedShort(): Incorrect value for out param",yOrig.value,z.value); assertEquals("testUnsignedShort(): Incorrect return value",x,ret); } } }

IterativeVerifier BranchVerifier InternalCallVerifier EqualityVerifier 
@Test public void testInt() throws Exception { if (!shouldRunTest("Int")) { return; } int valueSets[][]={{5,10},{-10,50},{Integer.MIN_VALUE,Integer.MAX_VALUE}}; for (int i=0; i < valueSets.length; i++) { int x=valueSets[i][0]; Holder yOrig=new Holder(valueSets[i][1]); Holder y=new Holder(valueSets[i][1]); Holder z=new Holder(); int ret; if (testDocLiteral) { ret=docClient.testInt(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testInt(x,y,z); } else { ret=rpcClient.testInt(x,y,z); } if (!perfTestOnly) { assertEquals("testInt(): Incorrect value for inout param",Integer.valueOf(x),y.value); assertEquals("testInt(): Incorrect value for out param",yOrig.value,z.value); assertEquals("testInt(): Incorrect return value",x,ret); } } }

BranchVerifier UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testSimpleRestriction3() throws Exception { if (!shouldRunTest("SimpleRestriction3")) { return; } String x="str_x"; String yOrig="string_yyy"; Holder y=new Holder(yOrig); Holder z=new Holder(); String ret; if (testDocLiteral) { ret=docClient.testSimpleRestriction3(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testSimpleRestriction3(x,y,z); } else { ret=rpcClient.testSimpleRestriction3(x,y,z); } if (!perfTestOnly) { assertEquals("testSimpleRestriction3(): Incorrect value for inout param",x,y.value); assertEquals("testSimpleRestriction3(): Incorrect value for out param",yOrig,z.value); assertEquals("testSimpleRestriction3(): Incorrect return value",x,ret); } if (testDocLiteral || testXMLBinding) { x="str"; y=new Holder(yOrig); z=new Holder(); try { ret=docClient.testSimpleRestriction3(x,y,z); fail("x parameter maxLength=10 && minLength=5 restriction is violated."); } catch ( Exception ex) { } x="string_x"; yOrig="string_yyyyyy"; y=new Holder(yOrig); z=new Holder(); try { ret=testDocLiteral ? docClient.testSimpleRestriction3(x,y,z) : xmlClient.testSimpleRestriction3(x,y,z); fail("y parameter maxLength=10 && minLength=5 restriction is violated."); } catch ( Exception ex) { } } }

IterativeVerifier BranchVerifier InternalCallVerifier EqualityVerifier 
@Test public void testUnsignedLong() throws Exception { if (!shouldRunTest("UnsignedLong")) { return; } BigInteger valueSets[][]={{new BigInteger("0"),new BigInteger("1")},{new BigInteger("1"),new BigInteger("0")},{new BigInteger("0"),new BigInteger(String.valueOf(Long.MAX_VALUE * Long.MAX_VALUE))}}; for (int i=0; i < valueSets.length; i++) { BigInteger x=valueSets[i][0]; Holder yOrig=new Holder(valueSets[i][1]); Holder y=new Holder(valueSets[i][1]); Holder z=new Holder(); BigInteger ret; if (testDocLiteral) { ret=docClient.testUnsignedLong(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testUnsignedLong(x,y,z); } else { ret=rpcClient.testUnsignedLong(x,y,z); } if (!perfTestOnly) { assertEquals("testUnsignedLong(): Incorrect value for inout param",x,y.value); assertEquals("testUnsignedLong(): Incorrect value for out param",yOrig.value,z.value); assertEquals("testUnsignedLong(): Incorrect return value",x,ret); } } }

IterativeVerifier BranchVerifier InternalCallVerifier EqualityVerifier 
@Test public void testNonNegativeInteger() throws Exception { if (!shouldRunTest("NonNegativeInteger")) { return; } BigInteger valueSets[][]={{new BigInteger("0"),new BigInteger("1234567890")},{new BigInteger(String.valueOf(Integer.MAX_VALUE * Integer.MAX_VALUE)),new BigInteger(String.valueOf(Long.MAX_VALUE * Long.MAX_VALUE))}}; for (int i=0; i < valueSets.length; i++) { BigInteger x=valueSets[i][0]; Holder yOrig=new Holder(valueSets[i][1]); Holder y=new Holder(valueSets[i][1]); Holder z=new Holder(); BigInteger ret; if (testDocLiteral) { ret=docClient.testNonNegativeInteger(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testNonNegativeInteger(x,y,z); } else { ret=rpcClient.testNonNegativeInteger(x,y,z); } if (!perfTestOnly) { assertEquals("testNonNegativeInteger(): Incorrect value for inout param",x,y.value); assertEquals("testNonNegativeInteger(): Incorrect value for out param",yOrig.value,z.value); assertEquals("testNonNegativeInteger(): Incorrect return value",x,ret); } } }

IterativeVerifier BranchVerifier InternalCallVerifier EqualityVerifier 
@Test public void testNegativeInteger() throws Exception { if (!shouldRunTest("NegativeInteger")) { return; } BigInteger valueSets[][]={{new BigInteger("-1"),new BigInteger("-1234567890")},{new BigInteger("-" + String.valueOf(Integer.MAX_VALUE * Integer.MAX_VALUE)),new BigInteger("-" + String.valueOf(Long.MAX_VALUE * Long.MAX_VALUE))}}; for (int i=0; i < valueSets.length; i++) { BigInteger x=valueSets[i][0]; Holder yOrig=new Holder(valueSets[i][1]); Holder y=new Holder(valueSets[i][1]); Holder z=new Holder(); BigInteger ret; if (testDocLiteral) { ret=docClient.testNegativeInteger(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testNegativeInteger(x,y,z); } else { ret=rpcClient.testNegativeInteger(x,y,z); } if (!perfTestOnly) { assertEquals("testNegativeInteger(): Incorrect value for inout param",x,y.value); assertEquals("testNegativeInteger(): Incorrect value for out param",yOrig.value,z.value); assertEquals("testNegativeInteger(): Incorrect return value",x,ret); } } }

IterativeVerifier BranchVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testSimpleListRestriction2() throws Exception { if (!shouldRunTest("SimpleListRestriction2")) { return; } if (testDocLiteral || testXMLBinding) { List x=Arrays.asList("I","am","SimpleList"); List yOrig=Arrays.asList("Does","SimpleList","Work"); Holder> y=new Holder>(yOrig); Holder> z=new Holder>(); List ret=testDocLiteral ? docClient.testSimpleListRestriction2(x,y,z) : xmlClient.testSimpleListRestriction2(x,y,z); if (!perfTestOnly) { assertTrue("testStringList(): Incorrect value for inout param",x.equals(y.value)); assertTrue("testStringList(): Incorrect value for out param",yOrig.equals(z.value)); assertTrue("testStringList(): Incorrect return value",x.equals(ret)); } x=new ArrayList(); y=new Holder>(yOrig); z=new Holder>(); try { ret=testDocLiteral ? docClient.testSimpleListRestriction2(x,y,z) : xmlClient.testSimpleListRestriction2(x,y,z); fail("length=10 restriction is violated."); } catch ( Exception ex) { } } else { String[] x={"I","am","SimpleList"}; String[] yOrig={"Does","SimpleList","Work"}; Holder y=new Holder(yOrig); Holder z=new Holder(); String[] ret=rpcClient.testSimpleListRestriction2(x,y,z); assertTrue(y.value.length == 3); assertTrue(z.value.length == 3); assertTrue(ret.length == 3); if (!perfTestOnly) { for (int i=0; i < 3; i++) { assertEquals("testStringList(): Incorrect value for inout param",x[i],y.value[i]); assertEquals("testStringList(): Incorrect value for out param",yOrig[i],z.value[i]); assertEquals("testStringList(): Incorrect return value",x[i],ret[i]); } } } }

IterativeVerifier BranchVerifier InternalCallVerifier EqualityVerifier 
@Test public void testByte() throws Exception { if (!shouldRunTest("Byte")) { return; } byte valueSets[][]={{0,1},{-1,0},{Byte.MIN_VALUE,Byte.MAX_VALUE}}; for (int i=0; i < valueSets.length; i++) { byte x=valueSets[i][0]; Holder yOrig=new Holder(valueSets[i][1]); Holder y=new Holder(valueSets[i][1]); Holder z=new Holder(); byte ret; if (testDocLiteral) { ret=docClient.testByte(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testByte(x,y,z); } else { ret=rpcClient.testByte(x,y,z); } if (!perfTestOnly) { assertEquals("testByte(): Incorrect value for inout param",Byte.valueOf(x),y.value); assertEquals("testByte(): Incorrect value for out param",yOrig.value,z.value); assertEquals("testByte(): Incorrect return value",x,ret); } } }

IterativeVerifier BranchVerifier InternalCallVerifier EqualityVerifier 
@Test public void testStringEnum() throws Exception { if (!shouldRunTest("StringEnum")) { return; } String[] xx={"a b c","d e f","g h i"}; String[] yy={"g h i","a b c","d e f"}; Holder z=new Holder(); for (int i=0; i < 3; i++) { StringEnum x=StringEnum.fromValue(xx[i]); StringEnum yOrig=StringEnum.fromValue(yy[i]); Holder y=new Holder(yOrig); StringEnum ret; if (testDocLiteral) { ret=docClient.testStringEnum(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testStringEnum(x,y,z); } else { ret=rpcClient.testStringEnum(x,y,z); } if (!perfTestOnly) { assertEquals("testStringEnum(): Incorrect value for inout param",x.value(),y.value.value()); assertEquals("testStringEnum(): Incorrect value for out param",yOrig.value(),z.value.value()); assertEquals("testStringEnum(): Incorrect return value",x.value(),ret.value()); } } }

IterativeVerifier BranchVerifier InternalCallVerifier EqualityVerifier 
@Test public void testAnyURIEnum() throws Exception { if (!shouldRunTest("AnyURIEnum")) { return; } String[] xx={"http://www.iona.com","http://www.google.com"}; String[] yy={"http://www.google.com","http://www.iona.com"}; Holder z=new Holder(); for (int i=0; i < 2; i++) { AnyURIEnum x=AnyURIEnum.fromValue(xx[i]); AnyURIEnum yOrig=AnyURIEnum.fromValue(yy[i]); Holder y=new Holder(yOrig); AnyURIEnum ret; if (testDocLiteral) { ret=docClient.testAnyURIEnum(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testAnyURIEnum(x,y,z); } else { ret=rpcClient.testAnyURIEnum(x,y,z); } if (!perfTestOnly) { assertEquals("testAnyURIEnum(): Incorrect value for inout param",x.value(),y.value.value()); assertEquals("testAnyURIEnum(): Incorrect value for out param",yOrig.value(),z.value.value()); assertEquals("testAnyURIEnum(): Incorrect return value",x.value(),ret.value()); } } }

IterativeVerifier BranchVerifier InternalCallVerifier EqualityVerifier 
@Test public void testAnyURI() throws Exception { if (!shouldRunTest("AnyURI")) { return; } String valueSets[][]={{"file:///root%20%20/-;?&+","file:///w:/test!artix~java*"},{"http://iona.com/","file:///z:/mail_iona=com,\'xmlbus\'"},{"mailto:windows@systems","file:///"}}; for (int i=0; i < valueSets.length; i++) { String x=new String(valueSets[i][0]); String yOrig=new String(valueSets[i][1]); Holder y=new Holder(yOrig); Holder z=new Holder(); String ret; if (testDocLiteral) { ret=docClient.testAnyURI(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testAnyURI(x,y,z); } else { ret=rpcClient.testAnyURI(x,y,z); } if (!perfTestOnly) { assertEquals("testAnyURI(): Incorrect value for inout param",x,y.value); assertEquals("testAnyURI(): Incorrect value for out param",yOrig,z.value); assertEquals("testAnyURI(): Incorrect return value",x,ret); } } }

IterativeVerifier BranchVerifier InternalCallVerifier EqualityVerifier 
@Test public void testBoolean() throws Exception { if (!shouldRunTest("Boolean")) { return; } boolean valueSets[][]={{true,false},{true,true},{false,true},{false,false}}; for (int i=0; i < valueSets.length; i++) { boolean x=valueSets[i][0]; Holder yOrig=new Holder(valueSets[i][1]); Holder y=new Holder(valueSets[i][1]); Holder z=new Holder(); boolean ret; if (testDocLiteral) { ret=docClient.testBoolean(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testBoolean(x,y,z); } else { ret=rpcClient.testBoolean(x,y,z); } if (!perfTestOnly) { assertEquals("testBoolean(): Incorrect value for inout param",Boolean.valueOf(x),y.value); assertEquals("testBoolean(): Incorrect value for out param",yOrig.value,z.value); assertEquals("testBoolean(): Incorrect return value",x,ret); } } }

IterativeVerifier BranchVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testFloat() throws Exception { if (!shouldRunTest("Float")) { return; } float delta=0.0f; float valueSets[][]=getTestFloatData(); for (int i=0; i < valueSets.length; i++) { float x=valueSets[i][0]; Holder yOrig=new Holder(valueSets[i][1]); Holder y=new Holder(valueSets[i][1]); Holder z=new Holder(); float ret; if (testDocLiteral) { ret=docClient.testFloat(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testFloat(x,y,z); } else { ret=rpcClient.testFloat(x,y,z); } if (!perfTestOnly) { assertEquals(i + ": testFloat(): Wrong value for inout param",x,y.value,delta); assertEquals(i + ": testFloat(): Wrong value for out param",yOrig.value,z.value,delta); assertEquals(i + ": testFloat(): Wrong return value",x,ret,delta); } } float x=Float.NaN; Holder yOrig=new Holder(0.0f); Holder y=new Holder(0.0f); Holder z=new Holder(); float ret; if (testDocLiteral) { ret=docClient.testFloat(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testFloat(x,y,z); } else { ret=rpcClient.testFloat(x,y,z); } if (!perfTestOnly) { assertTrue("testFloat(): Incorrect value for inout param",Float.isNaN(y.value)); assertEquals("testFloat(): Incorrect value for out param",yOrig.value,z.value,delta); assertTrue("testFloat(): Incorrect return value",Float.isNaN(ret)); } }

IterativeVerifier BranchVerifier InternalCallVerifier EqualityVerifier 
@Test public void testShort() throws Exception { if (!shouldRunTest("Short")) { return; } short valueSets[][]={{0,1},{-1,0},{Short.MIN_VALUE,Short.MAX_VALUE}}; for (int i=0; i < valueSets.length; i++) { short x=valueSets[i][0]; Holder yOrig=new Holder(valueSets[i][1]); Holder y=new Holder(valueSets[i][1]); Holder z=new Holder(); short ret; if (testDocLiteral) { ret=docClient.testShort(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testShort(x,y,z); } else { ret=rpcClient.testShort(x,y,z); } if (!perfTestOnly) { assertEquals("testShort(): Incorrect value for inout param",Short.valueOf(x),y.value); assertEquals("testShort(): Incorrect value for out param",yOrig.value,z.value); assertEquals("testShort(): Incorrect return value",x,ret); } } }

IterativeVerifier BranchVerifier InternalCallVerifier EqualityVerifier 
@Test public void testDecimal() throws Exception { if (!shouldRunTest("Decimal")) { return; } BigDecimal valueSets[][]={{new BigDecimal("-1234567890.000000"),new BigDecimal("1234567890.000000")},{new BigDecimal("-" + String.valueOf(Long.MAX_VALUE * Long.MAX_VALUE) + ".000000"),new BigDecimal(String.valueOf(Long.MAX_VALUE * Long.MAX_VALUE) + ".000000")}}; for (int i=0; i < valueSets.length; i++) { BigDecimal x=valueSets[i][0]; Holder yOrig=new Holder(valueSets[i][1]); Holder y=new Holder(valueSets[i][1]); Holder z=new Holder(); BigDecimal ret; if (testDocLiteral) { ret=docClient.testDecimal(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testDecimal(x,y,z); } else { ret=rpcClient.testDecimal(x,y,z); } if (!perfTestOnly) { assertEquals("testDecimal(): Incorrect value for inout param",x,y.value); assertEquals("testDecimal(): Incorrect value for out param",yOrig.value,z.value); assertEquals("testDecimal(): Incorrect return value",x,ret); } } }

IterativeVerifier BranchVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testNumberList() throws Exception { if (!shouldRunTest("NumberList")) { return; } if (testDocLiteral || testXMLBinding) { List x=Arrays.asList(1,2,3); List yOrig=Arrays.asList(10,100,1000); Holder> y=new Holder>(yOrig); Holder> z=new Holder>(); List ret=testDocLiteral ? docClient.testNumberList(x,y,z) : xmlClient.testNumberList(x,y,z); if (!perfTestOnly) { assertTrue("testNumberList(): Incorrect value for inout param",x.equals(y.value)); assertTrue("testNumberList(): Incorrect value for out param",yOrig.equals(z.value)); assertTrue("testNumberList(): Incorrect return value",x.equals(ret)); } } else { Integer[] x={1,2,3}; Integer[] yOrig={10,100,1000}; Holder y=new Holder(yOrig); Holder z=new Holder(); Integer[] ret=rpcClient.testNumberList(x,y,z); assertTrue(y.value.length == 3); assertTrue(z.value.length == 3); assertTrue(ret.length == 3); if (!perfTestOnly) { for (int i=0; i < 3; i++) { assertEquals("testNumberList(): Incorrect value for inout param",x[i],y.value[i]); assertEquals("testNumberList(): Incorrect value for out param",yOrig[i],z.value[i]); assertEquals("testNumberList(): Incorrect return value",x[i],ret[i]); } } } }

IterativeVerifier BranchVerifier InternalCallVerifier EqualityVerifier 
@Test public void testStringI18N() throws Exception { if (!shouldRunTest("StringI18N")) { return; } String valueSets[][]={{"hello",I18NStrings.CHINESE_COMPLEX_STRING},{"hello",I18NStrings.JAP_SIMPLE_STRING}}; for (int i=0; i < valueSets.length; i++) { String x=valueSets[i][0]; Holder yOrig=new Holder(valueSets[i][1]); Holder y=new Holder(valueSets[i][1]); Holder z=new Holder(); String ret; if (testDocLiteral) { ret=docClient.testString(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testString(x,y,z); } else { ret=rpcClient.testString(x,y,z); } if (!perfTestOnly) { assertEquals("testStringI18N(): Incorrect value for inout param",x,y.value); assertEquals("testStringI18N(): Incorrect value for out param",yOrig.value,z.value); assertEquals("testStringI18N(): Incorrect return value",x,ret); } } }

IterativeVerifier BranchVerifier InternalCallVerifier EqualityVerifier 
@Test public void testDecimalEnum() throws Exception { if (!shouldRunTest("DecimalEnum")) { return; } BigDecimal[] xx={new BigDecimal("-10.34"),new BigDecimal("11.22"),new BigDecimal("14.55")}; BigDecimal[] yy={new BigDecimal("14.55"),new BigDecimal("-10.34"),new BigDecimal("11.22")}; Holder z=new Holder(); for (int i=0; i < 3; i++) { DecimalEnum x=DecimalEnum.fromValue(xx[i]); DecimalEnum yOrig=DecimalEnum.fromValue(yy[i]); Holder y=new Holder(yOrig); DecimalEnum ret; if (testDocLiteral) { ret=docClient.testDecimalEnum(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testDecimalEnum(x,y,z); } else { ret=rpcClient.testDecimalEnum(x,y,z); } if (!perfTestOnly) { assertEquals("testDecimalEnum(): Incorrect value for inout param",x.value(),y.value.value()); assertEquals("testDecimalEnum(): Incorrect value for out param",yOrig.value(),z.value.value()); assertEquals("testDecimalEnum(): Incorrect return value",x.value(),ret.value()); } } }

IterativeVerifier BranchVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testStringList() throws Exception { if (!shouldRunTest("StringList")) { return; } if (testDocLiteral || testXMLBinding) { List x=Arrays.asList("I","am","SimpleList"); List yOrig=Arrays.asList("Does","SimpleList","Work"); Holder> y=new Holder>(yOrig); Holder> z=new Holder>(); List ret=testDocLiteral ? docClient.testStringList(x,y,z) : xmlClient.testStringList(x,y,z); if (!perfTestOnly) { assertTrue("testStringList(): Incorrect value for inout param",x.equals(y.value)); assertTrue("testStringList(): Incorrect value for out param",yOrig.equals(z.value)); assertTrue("testStringList(): Incorrect return value",x.equals(ret)); } if (testDocLiteral) { try { ret=docClient.testStringList(null,y,z); } catch ( SOAPFaultException ex) { assertTrue(ex.getMessage(),ex.getMessage().contains("Unmarshalling")); } } } else { String[] x={"I","am","SimpleList"}; String[] yOrig={"Does","SimpleList","Work"}; Holder y=new Holder(yOrig); Holder z=new Holder(); String[] ret=rpcClient.testStringList(x,y,z); assertTrue(y.value.length == 3); assertTrue(z.value.length == 3); assertTrue(ret.length == 3); if (!perfTestOnly) { for (int i=0; i < 3; i++) { assertEquals("testStringList(): Incorrect value for inout param",x[i],y.value[i]); assertEquals("testStringList(): Incorrect value for out param",yOrig[i],z.value[i]); assertEquals("testStringList(): Incorrect return value",x[i],ret[i]); } } } }

IterativeVerifier BranchVerifier InternalCallVerifier EqualityVerifier 
@Test public void testLong() throws Exception { if (!shouldRunTest("Long")) { return; } long valueSets[][]={{0,1},{-1,0},{Long.MIN_VALUE,Long.MAX_VALUE}}; for (int i=0; i < valueSets.length; i++) { long x=valueSets[i][0]; Holder yOrig=new Holder(valueSets[i][1]); Holder y=new Holder(valueSets[i][1]); Holder z=new Holder(); long ret; if (testDocLiteral) { ret=docClient.testLong(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testLong(x,y,z); } else { ret=rpcClient.testLong(x,y,z); } if (!perfTestOnly) { assertEquals("testLong(): Incorrect value for inout param",Long.valueOf(x),y.value); assertEquals("testLong(): Incorrect value for out param",yOrig.value,z.value); assertEquals("testLong(): Incorrect return value",x,ret); } } }

IterativeVerifier BranchVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testSimpleUnionList() throws Exception { if (!shouldRunTest("SimpleUnionList")) { return; } if (testDocLiteral || testXMLBinding) { List x=Arrays.asList("5","-7"); List yOrig=Arrays.asList("-9","7"); Holder> y=new Holder>(yOrig); Holder> z=new Holder>(); List ret=testDocLiteral ? docClient.testSimpleUnionList(x,y,z) : xmlClient.testSimpleUnionList(x,y,z); if (!perfTestOnly) { assertTrue("testSimpleUnionList(): Incorrect value for inout param",x.equals(y.value)); assertTrue("testSimpleUnionList(): Incorrect value for out param",yOrig.equals(z.value)); assertTrue("testSimpleUnionList(): Incorrect return value",x.equals(ret)); } } else { String[] x={"5","-7"}; String[] yOrig={"-9","7"}; Holder y=new Holder(yOrig); Holder z=new Holder(); String[] ret=rpcClient.testSimpleUnionList(x,y,z); assertTrue(y.value.length == 2); assertTrue(z.value.length == 2); assertTrue(ret.length == 2); if (!perfTestOnly) { for (int i=0; i < 2; i++) { assertEquals("testSimpleUnionList(): Incorrect value for inout param",x[i],y.value[i]); assertEquals("testSimpleUnionList(): Incorrect value for out param",yOrig[i],z.value[i]); assertEquals("testSimpleUnionList(): Incorrect return value",x[i],ret[i]); } } } }

IterativeVerifier BranchVerifier InternalCallVerifier EqualityVerifier 
@Test public void testNonPositiveInteger() throws Exception { if (!shouldRunTest("NonPositiveInteger")) { return; } BigInteger valueSets[][]={{new BigInteger("0"),new BigInteger("-1234567890")},{new BigInteger("-" + String.valueOf(Integer.MAX_VALUE * Integer.MAX_VALUE)),new BigInteger("-" + String.valueOf(Long.MAX_VALUE * Long.MAX_VALUE))}}; for (int i=0; i < valueSets.length; i++) { BigInteger x=valueSets[i][0]; Holder yOrig=new Holder(valueSets[i][1]); Holder y=new Holder(valueSets[i][1]); Holder z=new Holder(); BigInteger ret; if (testDocLiteral) { ret=docClient.testNonPositiveInteger(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testNonPositiveInteger(x,y,z); } else { ret=rpcClient.testNonPositiveInteger(x,y,z); } if (!perfTestOnly) { assertEquals("testNonPositiveInteger(): Incorrect value for inout param",x,y.value); assertEquals("testNonPositiveInteger(): Incorrect value for out param",yOrig.value,z.value); assertEquals("testNonPositiveInteger(): Incorrect return value",x,ret); } } }

BranchVerifier UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testSimpleRestriction() throws Exception { if (!shouldRunTest("SimpleRestriction")) { return; } String x="string_x"; String yOrig="string_y"; Holder y=new Holder(yOrig); Holder z=new Holder(); String ret; if (testDocLiteral) { ret=docClient.testSimpleRestriction(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testSimpleRestriction(x,y,z); } else { ret=rpcClient.testSimpleRestriction(x,y,z); } if (!perfTestOnly) { assertEquals("testSimpleRestriction(): Incorrect value for inout param",x,y.value); assertEquals("testSimpleRestriction(): Incorrect value for out param",yOrig,z.value); assertEquals("testSimpleRestriction(): Incorrect return value",x,ret); } if (testDocLiteral || testXMLBinding) { x="string_xxxxx"; y=new Holder(yOrig); z=new Holder(); try { ret=docClient.testSimpleRestriction(x,y,z); fail("x parameter maxLength=10 restriction is violated."); } catch ( Exception ex) { } x="string_x"; yOrig="string_yyyyyy"; y=new Holder(yOrig); z=new Holder(); try { ret=testDocLiteral ? docClient.testSimpleRestriction(x,y,z) : xmlClient.testSimpleRestriction(x,y,z); fail("y parameter maxLength=10 restriction is violated."); } catch ( Exception ex) { } } }

IterativeVerifier BranchVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testDouble() throws Exception { if (!shouldRunTest("Double")) { return; } double delta=0.0d; double valueSets[][]=getTestDoubleData(); for (int i=0; i < valueSets.length; i++) { double x=valueSets[i][0]; Holder yOrig=new Holder(valueSets[i][1]); Holder y=new Holder(valueSets[i][1]); Holder z=new Holder(); double ret; if (testDocLiteral) { ret=docClient.testDouble(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testDouble(x,y,z); } else { ret=rpcClient.testDouble(x,y,z); } if (!perfTestOnly) { assertEquals("testDouble(): Incorrect value for inout param",x,y.value,delta); assertEquals("testDouble(): Incorrect value for out param",yOrig.value,z.value,delta); assertEquals("testDouble(): Incorrect return value",x,ret,delta); } } double x=Double.NaN; Holder yOrig=new Holder(0.0); Holder y=new Holder(0.0); Holder z=new Holder(); double ret; if (testDocLiteral) { ret=docClient.testDouble(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testDouble(x,y,z); } else { ret=rpcClient.testDouble(x,y,z); } if (!perfTestOnly) { assertTrue("testDouble(): Incorrect value for inout param",Double.isNaN(y.value)); assertEquals("testDouble(): Incorrect value for out param",yOrig.value,z.value,delta); assertTrue("testDouble(): Incorrect return value",Double.isNaN(ret)); } }

APIUtilityVerifier IterativeVerifier BranchVerifier InternalCallVerifier EqualityVerifier 
@Test public void testString() throws Exception { if (!shouldRunTest("String")) { return; } int bufferSize=1000; StringBuilder buffer=new StringBuilder(bufferSize); StringBuilder buffer2=new StringBuilder(bufferSize); for (int x=0; x < bufferSize; x++) { buffer.append((char)('a' + (x % 26))); buffer2.append((char)('A' + (x % 26))); } String valueSets[][]={{"hello","world"},{"is pi > 3 ?"," is pi < 4\\\""},{"",""},{buffer.toString(),buffer2.toString()},{"jon&marry","marry&john"}}; for (int i=0; i < valueSets.length; i++) { String x=valueSets[i][0]; Holder yOrig=new Holder(valueSets[i][1]); Holder y=new Holder(valueSets[i][1]); Holder z=new Holder(); String ret; if (testDocLiteral) { ret=docClient.testString(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testString(x,y,z); } else { ret=rpcClient.testString(x,y,z); } if (!perfTestOnly) { assertEquals("testString(): Incorrect value for inout param",x,y.value); assertEquals("testString(): Incorrect value for out param",yOrig.value,z.value); assertEquals("testString(): Incorrect return value",x,ret); } } }

IterativeVerifier BranchVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testQNameList() throws Exception { if (!shouldRunTest("QNameList")) { return; } if (testDocLiteral || testXMLBinding) { List x=Arrays.asList(new QName("http://schemas.iona.com/type_test","testqname1"),new QName("http://schemas.iona.com/type_test","testqname2"),new QName("http://schemas.iona.com/type_test","testqname3")); List yOrig=Arrays.asList(new QName("http://schemas.iona.com/type_test","testqname4"),new QName("http://schemas.iona.com/type_test","testqname5"),new QName("http://schemas.iona.com/type_test","testqname6")); Holder> y=new Holder>(yOrig); Holder> z=new Holder>(); List ret=testDocLiteral ? docClient.testQNameList(x,y,z) : xmlClient.testQNameList(x,y,z); if (!perfTestOnly) { assertTrue("testQNameList(): Incorrect value for inout param",x.equals(y.value)); assertTrue("testQNameList(): Incorrect value for out param",yOrig.equals(z.value)); assertTrue("testQNameList(): Incorrect return value",x.equals(ret)); } } else { QName[] x={new QName("http://schemas.iona.com/type_test","testqname1"),new QName("http://schemas.iona.com/type_test","testqname2"),new QName("http://schemas.iona.com/type_test","testqname3")}; QName[] yOrig={new QName("http://schemas.iona.com/type_test","testqname4"),new QName("http://schemas.iona.com/type_test","testqname5"),new QName("http://schemas.iona.com/type_test","testqname6")}; Holder y=new Holder(yOrig); Holder z=new Holder(); QName[] ret=rpcClient.testQNameList(x,y,z); assertTrue(y.value.length == 3); assertTrue(z.value.length == 3); assertTrue(ret.length == 3); if (!perfTestOnly) { for (int i=0; i < 3; i++) { assertEquals("testQNameList(): Incorrect value for inout param",x[i],y.value[i]); assertEquals("testQNameList(): Incorrect value for out param",yOrig[i],z.value[i]); assertEquals("testQNameList(): Incorrect return value",x[i],ret[i]); } } } }

BranchVerifier UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testSimpleRestriction6() throws Exception { if (!shouldRunTest("SimpleRestriction6")) { return; } String x="str_x"; String yOrig="y"; Holder y=new Holder(yOrig); Holder z=new Holder(); String ret; if (testDocLiteral) { ret=docClient.testSimpleRestriction6(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testSimpleRestriction6(x,y,z); } else { ret=rpcClient.testSimpleRestriction6(x,y,z); } if (!perfTestOnly) { assertEquals("testSimpleRestriction6(): Incorrect value for inout param",x,y.value); assertEquals("testSimpleRestriction6(): Incorrect value for out param",yOrig,z.value); assertEquals("testSimpleRestriction6(): Incorrect return value",x,ret); } if (testDocLiteral || testXMLBinding) { x="string_x"; yOrig="string_y"; y=new Holder(yOrig); z=new Holder(); try { ret=testDocLiteral ? docClient.testSimpleRestriction6(x,y,z) : xmlClient.testSimpleRestriction6(x,y,z); fail("maxLength=10 && minLength=5 restriction is violated."); } catch ( Exception ex) { } } }

IterativeVerifier BranchVerifier InternalCallVerifier EqualityVerifier 
@Test public void testUnsignedInt() throws Exception { if (!shouldRunTest("UnsignedInt")) { return; } long valueSets[][]={{0,((long)Integer.MAX_VALUE) * 2 + 1},{11,20},{1,0}}; for (int i=0; i < valueSets.length; i++) { long x=valueSets[i][0]; long yOrig=valueSets[i][1]; Holder y=new Holder(valueSets[i][1]); Holder z=new Holder(); long ret; if (testDocLiteral) { ret=docClient.testUnsignedInt(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testUnsignedInt(x,y,z); } else { ret=rpcClient.testUnsignedInt(x,y,z); } if (!perfTestOnly) { assertEquals("testUnsignedInt(): Incorrect value for inout param",Long.valueOf(x),y.value); assertEquals("testUnsignedInt(): Incorrect value for out param",Long.valueOf(yOrig),z.value); assertEquals("testUnsignedInt(): Incorrect return value",x,ret); } } }

IterativeVerifier BranchVerifier InternalCallVerifier EqualityVerifier 
@Test public void testNMTokenEnum() throws Exception { if (!shouldRunTest("NMTokenEnum")) { return; } String[] xx={"hello","there"}; String[] yy={"there","hello"}; Holder z=new Holder(); for (int i=0; i < 2; i++) { NMTokenEnum x=NMTokenEnum.fromValue(xx[i]); NMTokenEnum yOrig=NMTokenEnum.fromValue(yy[i]); Holder y=new Holder(yOrig); NMTokenEnum ret; if (testDocLiteral) { ret=docClient.testNMTokenEnum(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testNMTokenEnum(x,y,z); } else { ret=rpcClient.testNMTokenEnum(x,y,z); } if (!perfTestOnly) { assertEquals("testNMTokenEnum(): Incorrect value for inout param",x.value(),y.value.value()); assertEquals("testNMTokenEnum(): Incorrect value for out param",yOrig.value(),z.value.value()); assertEquals("testNMTokenEnum(): Incorrect return value",x.value(),ret.value()); } } }

IterativeVerifier BranchVerifier InternalCallVerifier EqualityVerifier 
@Test public void testNumberEnum() throws Exception { if (!shouldRunTest("NumberEnum")) { return; } int[] xx={1,2,3}; int[] yy={3,1,2}; Holder z=new Holder(); for (int i=0; i < 3; i++) { NumberEnum x=NumberEnum.fromValue(xx[i]); NumberEnum yOrig=NumberEnum.fromValue(yy[i]); Holder y=new Holder(yOrig); NumberEnum ret; if (testDocLiteral) { ret=docClient.testNumberEnum(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testNumberEnum(x,y,z); } else { ret=rpcClient.testNumberEnum(x,y,z); } if (!perfTestOnly) { assertEquals("testNumberEnum(): Incorrect value for inout param",x.value(),y.value.value()); assertEquals("testNumberEnum(): Incorrect value for out param",yOrig.value(),z.value.value()); assertEquals("testNumberEnum(): Incorrect return value",x.value(),ret.value()); } } }

Class: org.apache.cxf.systest.type_test.AbstractTypeTestClient2

APIUtilityVerifier BranchVerifier InternalCallVerifier EqualityVerifier 
@Test public void testStructWithList() throws Exception { if (!shouldRunTest("StructWithList")) { return; } StructWithList x=new StructWithList(); x.getVarList().add("I"); x.getVarList().add("am"); x.getVarList().add("StructWithList"); StructWithList yOrig=new StructWithList(); yOrig.getVarList().add("Does"); yOrig.getVarList().add("StructWithList"); yOrig.getVarList().add("work"); Holder y=new Holder(yOrig); Holder z=new Holder(); StructWithList ret; if (testDocLiteral) { ret=docClient.testStructWithList(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testStructWithList(x,y,z); } else { ret=rpcClient.testStructWithList(x,y,z); } if (!perfTestOnly) { assertEquals("testStructWithList(): Incorrect value for inout param",x,y.value); assertEquals("testStructWithList(): Incorrect value for out param",yOrig,z.value); assertEquals("testStructWithList(): Incorrect return value",x,ret); } x.getAttribList().add(1); x.getAttribList().add(2); x.getAttribList().add(3); y.value=yOrig; if (testDocLiteral) { ret=docClient.testStructWithList(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testStructWithList(x,y,z); } else { ret=rpcClient.testStructWithList(x,y,z); } if (!perfTestOnly) { assertEquals("testStructWithList(): Incorrect value for inout param",x,y.value); assertEquals("testStructWithList(): Incorrect value for out param",yOrig,z.value); assertEquals("testStructWithList(): Incorrect return value",x,ret); } yOrig.getAttribList().add(4); yOrig.getAttribList().add(5); yOrig.getAttribList().add(6); y.value=yOrig; if (testDocLiteral) { ret=docClient.testStructWithList(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testStructWithList(x,y,z); } else { ret=rpcClient.testStructWithList(x,y,z); } if (!perfTestOnly) { assertEquals("testStructWithList(): Incorrect value for inout param",x,y.value); assertEquals("testStructWithList(): Incorrect value for out param",yOrig,z.value); assertEquals("testStructWithList(): Incorrect return value",x,ret); } }

APIUtilityVerifier IterativeVerifier BranchVerifier InternalCallVerifier EqualityVerifier 
@Test public void testFixedArray() throws Exception { if (!shouldRunTest("FixedArray")) { return; } FixedArray x=new FixedArray(); x.getItem().addAll(Arrays.asList(Integer.MIN_VALUE,0,Integer.MAX_VALUE)); FixedArray yOrig=new FixedArray(); yOrig.getItem().addAll(Arrays.asList(-1,0,1)); Holder y=new Holder(yOrig); Holder z=new Holder(); FixedArray ret; if (testDocLiteral) { ret=docClient.testFixedArray(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testFixedArray(x,y,z); } else { ret=rpcClient.testFixedArray(x,y,z); } if (!perfTestOnly) { for (int i=0; i < 3; i++) { assertEquals("testFixedArray(): Incorrect value for inout param",x.getItem().get(i),y.value.getItem().get(i)); assertEquals("testFixedArray(): Incorrect value for out param",yOrig.getItem().get(i),z.value.getItem().get(i)); assertEquals("testFixedArray(): Incorrect return value",x.getItem().get(i),ret.getItem().get(i)); } } }

APIUtilityVerifier IterativeVerifier BranchVerifier InternalCallVerifier EqualityVerifier 
@Test public void testNestedArray() throws Exception { if (!shouldRunTest("NestedArray")) { return; } String[][] xs={{"AAA","BBB","CCC"},{"aaa","bbb","ccc"},{"a_a_a","b_b_b","c_c_c"}}; String[][] ys={{"XXX","YYY","ZZZ"},{"xxx","yyy","zzz"},{"x_x_x","y_y_y","z_z_z"}}; NestedArray x=new NestedArray(); NestedArray yOrig=new NestedArray(); List xList=x.getSubarray(); List yList=yOrig.getSubarray(); for (int i=0; i < 3; i++) { UnboundedArray xx=new UnboundedArray(); xx.getItem().addAll(Arrays.asList(xs[i])); xList.add(xx); UnboundedArray yy=new UnboundedArray(); yy.getItem().addAll(Arrays.asList(ys[i])); yList.add(yy); } Holder y=new Holder(yOrig); Holder z=new Holder(); NestedArray ret; if (testDocLiteral) { ret=docClient.testNestedArray(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testNestedArray(x,y,z); } else { ret=rpcClient.testNestedArray(x,y,z); } if (!perfTestOnly) { for (int i=0; i < 3; i++) { for (int j=0; j < 3; j++) { assertEquals("testNestedArray(): Incorrect value for inout param",x.getSubarray().get(i).getItem().get(j),y.value.getSubarray().get(i).getItem().get(j)); assertEquals("testNestedArray(): Incorrect value for out param",yOrig.getSubarray().get(i).getItem().get(j),z.value.getSubarray().get(i).getItem().get(j)); assertEquals("testNestedArray(): Incorrect return value",x.getSubarray().get(i).getItem().get(j),ret.getSubarray().get(i).getItem().get(j)); } } } }

APIUtilityVerifier BranchVerifier InternalCallVerifier EqualityVerifier 
@Test public void testUnionSimpleContent() throws Exception { if (!shouldRunTest("UnionSimpleContent")) { return; } UnionSimpleContent x=new UnionSimpleContent(); x.setValue("5"); UnionSimpleContent yOrig=new UnionSimpleContent(); yOrig.setValue("-7"); Holder y=new Holder(yOrig); Holder z=new Holder(); UnionSimpleContent ret; if (testDocLiteral) { ret=docClient.testUnionSimpleContent(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testUnionSimpleContent(x,y,z); } else { ret=rpcClient.testUnionSimpleContent(x,y,z); } if (!perfTestOnly) { assertEquals("testUnionSimpleContent(): Incorrect value for inout param",x,y.value); assertEquals("testUnionSimpleContent(): Incorrect value for out param",yOrig,z.value); assertEquals("testUnionSimpleContent(): Incorrect return value",x,ret); } }

APIUtilityVerifier IterativeVerifier BranchVerifier BooleanVerifier InternalCallVerifier EqualityVerifier PublicFieldVerifier HybridVerifier 
@Test public void testBoundedArray() throws Exception { if (!shouldRunTest("BoundedArray")) { return; } BoundedArray x=new BoundedArray(); x.getItem().addAll(Arrays.asList(-100.00f,0f,100.00f)); BoundedArray yOrig=new BoundedArray(); yOrig.getItem().addAll(Arrays.asList(-1f,0f,1f)); Holder y=new Holder(yOrig); Holder z=new Holder(); BoundedArray ret; if (testDocLiteral) { ret=docClient.testBoundedArray(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testBoundedArray(x,y,z); } else { ret=rpcClient.testBoundedArray(x,y,z); } if (!perfTestOnly) { float delta=0.0f; int xSize=x.getItem().size(); int ySize=y.value.getItem().size(); int zSize=z.value.getItem().size(); int retSize=ret.getItem().size(); assertTrue("testBoundedArray() array size incorrect",xSize == ySize && ySize == zSize && zSize == retSize && xSize == 3); for (int i=0; i < xSize; i++) { assertEquals("testBoundedArray(): Incorrect value for inout param",x.getItem().get(i),y.value.getItem().get(i),delta); assertEquals("testBoundedArray(): Incorrect value for out param",yOrig.getItem().get(i),z.value.getItem().get(i),delta); assertEquals("testBoundedArray(): Incorrect return value",x.getItem().get(i),ret.getItem().get(i),delta); } } }

APIUtilityVerifier BranchVerifier InternalCallVerifier EqualityVerifier 
@Test public void testExtendsSimpleContent() throws Exception { if (!shouldRunTest("ExtendsSimpleContent")) { return; } ExtendsSimpleContent x=new ExtendsSimpleContent(); x.setValue("foo"); ExtendsSimpleContent yOriginal=new ExtendsSimpleContent(); yOriginal.setValue("bar"); Holder y=new Holder(yOriginal); Holder z=new Holder(); ExtendsSimpleContent ret; if (testDocLiteral) { ret=docClient.testExtendsSimpleContent(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testExtendsSimpleContent(x,y,z); } else { ret=rpcClient.testExtendsSimpleContent(x,y,z); } if (!perfTestOnly) { assertEquals(x.getValue(),y.value.getValue()); assertEquals(yOriginal.getValue(),z.value.getValue()); assertEquals(x.getValue(),ret.getValue()); } }

APIUtilityVerifier BranchVerifier InternalCallVerifier EqualityVerifier 
@Test public void testExtendsSimpleType() throws Exception { if (!shouldRunTest("ExtendsSimpleType")) { return; } ExtendsSimpleType x=new ExtendsSimpleType(); x.setValue("foo"); ExtendsSimpleType yOriginal=new ExtendsSimpleType(); yOriginal.setValue("bar"); Holder y=new Holder(yOriginal); Holder z=new Holder(); ExtendsSimpleType ret; if (testDocLiteral) { ret=docClient.testExtendsSimpleType(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testExtendsSimpleType(x,y,z); } else { ret=rpcClient.testExtendsSimpleType(x,y,z); } if (!perfTestOnly) { assertEquals(x.getValue(),y.value.getValue()); assertEquals(yOriginal.getValue(),z.value.getValue()); assertEquals(x.getValue(),ret.getValue()); } }

APIUtilityVerifier BranchVerifier InternalCallVerifier EqualityVerifier 
@Test public void testStructWithUnion() throws Exception { if (!shouldRunTest("StructWithUnion")) { return; } StructWithUnion x=new StructWithUnion(); x.setVarUnion("999"); StructWithUnion yOrig=new StructWithUnion(); yOrig.setVarUnion("-999"); Holder y=new Holder(yOrig); Holder z=new Holder(); StructWithUnion ret; if (testDocLiteral) { ret=docClient.testStructWithUnion(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testStructWithUnion(x,y,z); } else { ret=rpcClient.testStructWithUnion(x,y,z); } if (!perfTestOnly) { assertEquals("testStructWithUnion(): Incorrect value for inout param",x,y.value); assertEquals("testStructWithUnion(): Incorrect value for out param",yOrig,z.value); assertEquals("testStructWithUnion(): Incorrect return value",x,ret); } x.setAttribUnion("99"); y.value=yOrig; if (testDocLiteral) { ret=docClient.testStructWithUnion(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testStructWithUnion(x,y,z); } else { ret=rpcClient.testStructWithUnion(x,y,z); } if (!perfTestOnly) { assertEquals("testStructWithUnion(): Incorrect value for inout param",x,y.value); assertEquals("testStructWithUnion(): Incorrect value for out param",yOrig,z.value); assertEquals("testStructWithUnion(): Incorrect return value",x,ret); } yOrig.setAttribUnion("-99"); y.value=yOrig; if (testDocLiteral) { ret=docClient.testStructWithUnion(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testStructWithUnion(x,y,z); } else { ret=rpcClient.testStructWithUnion(x,y,z); } if (!perfTestOnly) { assertEquals("testStructWithUnion(): Incorrect value for inout param",x,y.value); assertEquals("testStructWithUnion(): Incorrect value for out param",yOrig,z.value); assertEquals("testStructWithUnion(): Incorrect return value",x,ret); } }

Class: org.apache.cxf.systest.type_test.AbstractTypeTestClient3

APIUtilityVerifier IterativeVerifier BranchVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testAnonEnumList() throws Exception { if (!shouldRunTest("AnonEnumList")) { return; } if (testDocLiteral || testXMLBinding) { List x=Arrays.asList((short)10,(short)100); List yOrig=Arrays.asList((short)1000,(short)10); Holder> y=new Holder>(yOrig); Holder> z=new Holder>(); List ret=testDocLiteral ? docClient.testAnonEnumList(x,y,z) : xmlClient.testAnonEnumList(x,y,z); if (!perfTestOnly) { assertTrue("testAnonEnumList(): Incorrect value for inout param",x.equals(y.value)); assertTrue("testAnonEnumList(): Incorrect value for out param",yOrig.equals(z.value)); assertTrue("testAnonEnumList(): Incorrect return value",x.equals(ret)); } } else { Short[] x={(short)10,(short)100}; Short[] yOrig={(short)1000,(short)10}; Holder y=new Holder(yOrig); Holder z=new Holder(); Short[] ret=rpcClient.testAnonEnumList(x,y,z); assertTrue(y.value.length == 2); assertTrue(z.value.length == 2); assertTrue(ret.length == 2); if (!perfTestOnly) { for (int i=0; i < 2; i++) { assertEquals("testAnonEnumList(): Incorrect value for inout param",x[i].shortValue(),y.value[i].shortValue()); assertEquals("testAnonEnumList(): Incorrect value for out param",yOrig[i].shortValue(),z.value[i].shortValue()); assertEquals("testAnonEnumList(): Incorrect return value",x[i].shortValue(),ret[i].shortValue()); } } } }

APIUtilityVerifier EqualityVerifier 
@Test public void testUnionWithAnonEnum() throws Exception { if (!shouldRunTest("UnionWithAnonEnum")) { return; } String x="5"; String yOrig="n/a"; Holder y=new Holder(yOrig); Holder z=new Holder(); String ret; if (testDocLiteral) { ret=docClient.testUnionWithAnonEnum(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testUnionWithAnonEnum(x,y,z); } else { ret=rpcClient.testUnionWithAnonEnum(x,y,z); } assertEquals("testUnionWithAnonEnum(): Incorrect value for inout param",x,y.value); assertEquals("testUnionWithAnonEnum(): Incorrect value for out param",yOrig,z.value); assertEquals("testUnionWithAnonEnum(): Incorrect return value",x,ret); }

Class: org.apache.cxf.systest.type_test.AbstractTypeTestClient4

APIUtilityVerifier BranchVerifier UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testAnyURIRestriction() throws Exception { if (!shouldRunTest("AnyURIRestriction")) { return; } String x=new String("http://cxf.apache.org/"); String yOrig=new String("http://www.iona.com/info/services/oss/"); Holder y=new Holder(yOrig); Holder z=new Holder(); String ret; if (testDocLiteral) { ret=docClient.testAnyURIRestriction(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testAnyURIRestriction(x,y,z); } else { ret=rpcClient.testAnyURIRestriction(x,y,z); } if (!perfTestOnly) { assertEquals("testString(): Incorrect value for inout param",x,y.value); assertEquals("testString(): Incorrect value for out param",yOrig,z.value); assertEquals("testString(): Incorrect return value",x,ret); } if (testDocLiteral || testXMLBinding) { yOrig=new String("http://www.iona.com/info/services/oss/info_services_oss_train.html"); y=new Holder(yOrig); z=new Holder(); try { ret=testDocLiteral ? docClient.testAnyURIRestriction(x,y,z) : xmlClient.testAnyURIRestriction(x,y,z); fail("maxLength=50 restriction is violated."); } catch ( Exception ex) { } } }

APIUtilityVerifier BranchVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testUnionWithAnonList() throws Exception { if (!shouldRunTest("UnionWithAnonList")) { return; } if (testDocLiteral || testXMLBinding) { List x=Arrays.asList("5"); List yOrig=Arrays.asList("-1E4","1267.43233E12","12.78e-2","12","-0","INF"); Holder> y=new Holder>(yOrig); Holder> z=new Holder>(); List ret=testDocLiteral ? docClient.testUnionWithAnonList(x,y,z) : xmlClient.testUnionWithAnonList(x,y,z); if (!perfTestOnly) { assertEquals("testUnionWithAnonList(): Incorrect value for inout param",x,y.value); assertEquals("testUnionWithAnonList(): Incorrect value for out param",yOrig,z.value); assertEquals("testUnionWithAnonList(): Incorrect return value",x,ret); } } else { String[] x={"5"}; String[] yOrig={"-1E4","1267.43233E12","12.78e-2","12","-0","INF"}; Holder y=new Holder(yOrig); Holder z=new Holder(); String[] ret=rpcClient.testUnionWithStringListRestriction(x,y,z); if (!perfTestOnly) { assertTrue("testUnionWithAnonList(): Incorrect value for inout param",Arrays.equals(x,y.value)); assertTrue("testUnionWithAnonList(): Incorrect value for out param",Arrays.equals(yOrig,z.value)); assertTrue("testUnionWithAnonList(): Incorrect return value",Arrays.equals(x,ret)); } } }

APIUtilityVerifier BranchVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testUnionWithStringListRestriction() throws Exception { if (!shouldRunTest("UnionWithStringListRestriction")) { return; } if (testDocLiteral || testXMLBinding) { List x=Arrays.asList("5"); List yOrig=Arrays.asList("I","am","SimpleList"); Holder> y=new Holder>(yOrig); Holder> z=new Holder>(); List ret=testDocLiteral ? docClient.testUnionWithStringListRestriction(x,y,z) : xmlClient.testUnionWithStringListRestriction(x,y,z); if (!perfTestOnly) { assertEquals("testUnionWithStringListRestriction(): Incorrect value for inout param",x,y.value); assertEquals("testUnionWithStringListRestriction(): Incorrect value for out param",yOrig,z.value); assertEquals("testUnionWithStringListRestriction(): Incorrect return value",x,ret); } } else { String[] x={"5"}; String[] yOrig={"I","am","SimpleList"}; Holder y=new Holder(yOrig); Holder z=new Holder(); String[] ret=rpcClient.testUnionWithStringListRestriction(x,y,z); if (!perfTestOnly) { assertTrue("testUnionWithStringListRestriction(): Incorrect value for inout param",Arrays.equals(x,y.value)); assertTrue("testUnionWithStringListRestriction(): Incorrect value for out param",Arrays.equals(yOrig,z.value)); assertTrue("testUnionWithStringListRestriction(): Incorrect return value",Arrays.equals(x,ret)); } } }

APIUtilityVerifier BranchVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testUnionWithStringList() throws Exception { if (!shouldRunTest("UnionWithStringList")) { return; } if (testDocLiteral || testXMLBinding) { List x=Arrays.asList("5"); List yOrig=Arrays.asList("I","am","SimpleList"); Holder> y=new Holder>(yOrig); Holder> z=new Holder>(); List ret=testDocLiteral ? docClient.testUnionWithStringList(x,y,z) : xmlClient.testUnionWithStringList(x,y,z); if (!perfTestOnly) { assertEquals("testUnionWithStringList(): Incorrect value for inout param",x,y.value); assertEquals("testUnionWithStringList(): Incorrect value for out param",yOrig,z.value); assertEquals("testUnionWithStringList(): Incorrect return value",x,ret); } } else { String[] x={"5"}; String[] yOrig={"I","am","SimpleList"}; Holder y=new Holder(yOrig); Holder z=new Holder(); String[] ret=rpcClient.testUnionWithStringList(x,y,z); if (!perfTestOnly) { assertTrue("testUnionWithStringList(): Incorrect value for inout param",Arrays.equals(x,y.value)); assertTrue("testUnionWithStringList(): Incorrect value for out param",Arrays.equals(yOrig,z.value)); assertTrue("testUnionWithStringList(): Incorrect return value",Arrays.equals(x,ret)); } } }

Class: org.apache.cxf.systest.type_test.AbstractTypeTestClient5

APIUtilityVerifier BranchVerifier UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testComplexRestriction() throws Exception { if (!shouldRunTest("ComplexRestriction")) { return; } ComplexRestriction x=new ComplexRestriction(); x.setValue("str_x"); ComplexRestriction yOrig=new ComplexRestriction(); yOrig.setValue("string_yyy"); Holder y=new Holder(yOrig); Holder z=new Holder(); ComplexRestriction ret; if (testDocLiteral) { ret=docClient.testComplexRestriction(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testComplexRestriction(x,y,z); } else { ret=rpcClient.testComplexRestriction(x,y,z); } if (!perfTestOnly) { assertEquals("testComplexRestriction(): Incorrect value for inout param",x.getValue(),y.value.getValue()); assertEquals("testComplexRestriction(): Incorrect value for out param",yOrig.getValue(),z.value.getValue()); assertEquals("testComplexRestriction(): Incorrect return value",x.getValue(),ret.getValue()); } if (testDocLiteral || testXMLBinding) { try { x=new ComplexRestriction(); x.setValue("string_x"); yOrig=new ComplexRestriction(); yOrig.setValue("string_yyyyyy"); y=new Holder(yOrig); z=new Holder(); ret=testDocLiteral ? docClient.testComplexRestriction(x,y,z) : xmlClient.testComplexRestriction(x,y,z); fail("maxLength=10 restriction is violated."); } catch ( Exception ex) { } } }

APIUtilityVerifier BranchVerifier UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testComplexRestriction2() throws Exception { if (!shouldRunTest("ComplexRestriction2")) { return; } ComplexRestriction2 x=new ComplexRestriction2(); x.setValue("string_xxx"); ComplexRestriction2 yOrig=new ComplexRestriction2(); yOrig.setValue("string_yyy"); Holder y=new Holder(yOrig); Holder z=new Holder(); ComplexRestriction2 ret; if (testDocLiteral) { ret=docClient.testComplexRestriction2(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testComplexRestriction2(x,y,z); } else { ret=rpcClient.testComplexRestriction2(x,y,z); } if (!perfTestOnly) { assertEquals("testComplexRestriction2(): Incorrect value for inout param",x.getValue(),y.value.getValue()); assertEquals("testComplexRestriction2(): Incorrect value for out param",yOrig.getValue(),z.value.getValue()); assertEquals("testComplexRestriction2(): Incorrect return value",x.getValue(),ret.getValue()); } if (testDocLiteral || testXMLBinding) { try { x=new ComplexRestriction2(); x.setValue("str_x"); yOrig=new ComplexRestriction2(); yOrig.setValue("string_yyy"); y=new Holder(yOrig); z=new Holder(); ret=testDocLiteral ? docClient.testComplexRestriction2(x,y,z) : xmlClient.testComplexRestriction2(x,y,z); fail("length=10 restriction is violated."); } catch ( Exception ex) { } } }

APIUtilityVerifier BranchVerifier UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testComplexRestriction4() throws Exception { if (!shouldRunTest("ComplexRestriction4")) { return; } ComplexRestriction4 x=new ComplexRestriction4(); x.setValue("str_x"); ComplexRestriction4 yOrig=new ComplexRestriction4(); yOrig.setValue("y"); Holder y=new Holder(yOrig); Holder z=new Holder(); ComplexRestriction4 ret; if (testDocLiteral) { ret=docClient.testComplexRestriction4(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testComplexRestriction4(x,y,z); } else { ret=rpcClient.testComplexRestriction4(x,y,z); } if (!perfTestOnly) { assertEquals("testComplexRestriction4(): Incorrect value for inout param",x.getValue(),y.value.getValue()); assertEquals("testComplexRestriction4(): Incorrect value for out param",yOrig.getValue(),z.value.getValue()); assertEquals("testComplexRestriction4(): Incorrect return value",x.getValue(),ret.getValue()); } if (testDocLiteral || testXMLBinding) { try { x=new ComplexRestriction4(); x.setValue("str_xxx"); y=new Holder(yOrig); z=new Holder(); ret=testDocLiteral ? docClient.testComplexRestriction4(x,y,z) : xmlClient.testComplexRestriction4(x,y,z); fail("maxLength=5 restriction is violated."); } catch ( Exception ex) { } } }

APIUtilityVerifier BranchVerifier UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testComplexRestriction3() throws Exception { if (!shouldRunTest("ComplexRestriction3")) { return; } ComplexRestriction3 x=new ComplexRestriction3(); x.setValue("str_x"); ComplexRestriction3 yOrig=new ComplexRestriction3(); yOrig.setValue("string_yyy"); Holder y=new Holder(yOrig); Holder z=new Holder(); ComplexRestriction3 ret; if (testDocLiteral) { ret=docClient.testComplexRestriction3(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testComplexRestriction3(x,y,z); } else { ret=rpcClient.testComplexRestriction3(x,y,z); } if (!perfTestOnly) { assertEquals("testComplexRestriction3(): Incorrect value for inout param",x.getValue(),y.value.getValue()); assertEquals("testComplexRestriction3(): Incorrect value for out param",yOrig.getValue(),z.value.getValue()); assertEquals("testComplexRestriction3(): Incorrect return value",x.getValue(),ret.getValue()); } if (testDocLiteral || testXMLBinding) { try { x=new ComplexRestriction3(); x.setValue("str"); y=new Holder(yOrig); z=new Holder(); ret=testDocLiteral ? docClient.testComplexRestriction3(x,y,z) : xmlClient.testComplexRestriction3(x,y,z); fail("maxLength=10 && minLength=5 restriction is violated."); } catch ( Exception ex) { } try { x=new ComplexRestriction3(); x.setValue("string_x"); yOrig=new ComplexRestriction3(); yOrig.setValue("string_yyyyyy"); y=new Holder(yOrig); z=new Holder(); ret=testDocLiteral ? docClient.testComplexRestriction3(x,y,z) : xmlClient.testComplexRestriction3(x,y,z); fail("maxLength=10 && minLength=5 restriction is violated."); } catch ( Exception ex) { } } }

APIUtilityVerifier BranchVerifier UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testComplexRestriction5() throws Exception { if (!shouldRunTest("ComplexRestriction5")) { return; } ComplexRestriction5 x=new ComplexRestriction5(); x.setValue("http://www.iona.com"); ComplexRestriction5 yOrig=new ComplexRestriction5(); yOrig.setValue("http://www.iona.com/info/services/oss/"); Holder y=new Holder(yOrig); Holder z=new Holder(); ComplexRestriction5 ret; if (testDocLiteral) { ret=docClient.testComplexRestriction5(x,y,z); } else if (testXMLBinding) { ret=xmlClient.testComplexRestriction5(x,y,z); } else { ret=rpcClient.testComplexRestriction5(x,y,z); } if (!perfTestOnly) { assertEquals("testComplexRestriction5(): Incorrect value for inout param",x.getValue(),y.value.getValue()); assertEquals("testComplexRestriction5(): Incorrect value for out param",yOrig.getValue(),z.value.getValue()); assertEquals("testComplexRestriction5(): Incorrect return value",x.getValue(),ret.getValue()); } if (testDocLiteral || testXMLBinding) { try { x=new ComplexRestriction5(); x.setValue("uri"); y=new Holder(yOrig); z=new Holder(); ret=docClient.testComplexRestriction5(x,y,z); fail("maxLength=50 && minLength=5 restriction is violated."); } catch ( Exception ex) { } try { x=new ComplexRestriction5(); x.setValue("http://www.iona.com"); yOrig=new ComplexRestriction5(); yOrig.setValue("http://www.iona.com/info/services/oss/info_services_oss_train.html"); y=new Holder(yOrig); z=new Holder(); ret=testDocLiteral ? docClient.testComplexRestriction5(x,y,z) : xmlClient.testComplexRestriction5(x,y,z); fail("maxLength=50 && minLength=5 restriction is violated."); } catch ( Exception ex) { } } }

Class: org.apache.cxf.systest.versioning.ClientServerVersioningTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testVersionBasedRouting() throws Exception { SOAPService service=new SOAPService(); assertNotNull(service); try { Greeter greeter=service.getPort(portName,Greeter.class); updateAddressPort(greeter,PORT); GreetMe1 request=new GreetMe1(); request.setRequestType("Bonjour"); GreetMeResponse greeting=greeter.greetMe(request); assertNotNull("no response received from service",greeting); assertEquals("Hello Bonjour version1",greeting.getResponseType()); String reply=greeter.sayHi(); assertNotNull("no response received from service",reply); assertEquals("Bonjour version2",reply); } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

Class: org.apache.cxf.systest.ws.addr_disable.WSADisableTest

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testDisableServerSide() throws Exception { ByteArrayOutputStream input=setupInLogging(); ByteArrayOutputStream output=setupOutLogging(); AddNumbersPortType port=getService().getAddNumbersPort(); ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,"http://localhost:" + PORT + "/jaxws/add"); assertEquals(3,port.addNumbers(1,2)); String expectedOut="http://apache.org/cxf/systest/ws/addr_feature/AddNumbersPortType/addNumbersRequest"; String expectedIn="http://www.w3.org/2005/08/addressing"; assertLogContains(output.toString(),"//wsa:Action",expectedOut); assertTrue(input.toString().indexOf(expectedIn) == -1); }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testDisableAll() throws Exception { ByteArrayOutputStream input=setupInLogging(); ByteArrayOutputStream output=setupOutLogging(); AddNumbersPortType port=getService().getAddNumbersPort(new AddressingFeature(false)); ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,"http://localhost:" + PORT + "/jaxws/add"); assertEquals(3,port.addNumbers(1,2)); String expectedOut="http://www.w3.org/2005/08/addressing"; String expectedIn="http://www.w3.org/2005/08/addressing"; assertTrue(output.toString().indexOf(expectedOut) == -1); assertTrue(input.toString().indexOf(expectedIn) == -1); }

Class: org.apache.cxf.systest.ws.addr_feature.WSAClientServerTest

InternalCallVerifier EqualityVerifier 
@Test public void testCxfWsaFeature() throws Exception { ByteArrayOutputStream input=setupInLogging(); ByteArrayOutputStream output=setupOutLogging(); JaxWsProxyFactoryBean factory=new JaxWsProxyFactoryBean(); factory.setServiceClass(AddNumbersPortType.class); factory.setAddress("http://localhost:" + PORT + "/jaxws/add"); factory.getFeatures().add(new WSAddressingFeature()); AddNumbersPortType port=(AddNumbersPortType)factory.create(); ((BindingProvider)port).getRequestContext().put("ws-addressing.write.optional.replyto",Boolean.TRUE); assertEquals(3,port.addNumbers(1,2)); assertLogContains(output.toString(),"//wsa:Address","http://www.w3.org/2005/08/addressing/anonymous"); assertLogContains(input.toString(),"//wsa:RelatesTo",getLogValue(output.toString(),"//wsa:MessageID")); }

EqualityVerifier 
@Test public void testJaxwsWsaFeature() throws Exception { ByteArrayOutputStream input=setupInLogging(); ByteArrayOutputStream output=setupOutLogging(); AddNumbersPortType port=getPort(); ((BindingProvider)port).getRequestContext().put("ws-addressing.write.optional.replyto",Boolean.TRUE); assertEquals(3,port.addNumbers(1,2)); assertLogContains(output.toString(),"//wsa:Address","http://www.w3.org/2005/08/addressing/anonymous"); assertLogContains(input.toString(),"//wsa:RelatesTo",getLogValue(output.toString(),"//wsa:MessageID")); }

InternalCallVerifier EqualityVerifier 
@Test public void testNoWsaFeature() throws Exception { ByteArrayOutputStream input=setupInLogging(); ByteArrayOutputStream output=setupOutLogging(); JaxWsProxyFactoryBean factory=new JaxWsProxyFactoryBean(); factory.setServiceClass(AddNumbersPortType.class); factory.setAddress("http://localhost:" + PORT + "/jaxws/add"); AddNumbersPortType port=(AddNumbersPortType)factory.create(); assertEquals(3,port.addNumbers(1,2)); assertLogNotContains(output.toString(),"//wsa:Address"); assertLogNotContains(input.toString(),"//wsa:RelatesTo"); }

Class: org.apache.cxf.systest.ws.addr_fromjava.WSAFromJavaTest

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testAddNumbers() throws Exception { ByteArrayOutputStream input=setupInLogging(); ByteArrayOutputStream output=setupOutLogging(); AddNumberImpl port=getPort(); assertEquals(3,port.addNumbers(1,2)); String expectedOut="http://cxf.apache.org/input"; assertTrue(output.toString().indexOf(expectedOut) != -1); String expectedIn="http://cxf.apache.org/output"; assertTrue(input.toString().indexOf(expectedIn) != -1); }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testAddNumbers2() throws Exception { ByteArrayOutputStream input=setupInLogging(); ByteArrayOutputStream output=setupOutLogging(); AddNumberImpl port=getPort(); assertEquals(3,port.addNumbers2(1,2)); String base="http://server.addr_fromjava.ws.systest.cxf.apache.org/AddNumberImpl"; String expectedOut=base + "/addNumbers2"; assertTrue(output.toString().indexOf(expectedOut) != -1); String expectedIn=base + "/addNumbers2Response"; assertTrue(input.toString().indexOf(expectedIn) != -1); }

UtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testAddNumbersJaxWsContext() throws Exception { ByteArrayOutputStream output=setupOutLogging(); AddNumberImpl port=getPort(); BindingProvider bp=(BindingProvider)port; java.util.Map requestContext=bp.getRequestContext(); requestContext.put(BindingProvider.SOAPACTION_URI_PROPERTY,"cxf"); try { assertEquals(3,port.addNumbers(1,2)); fail("Should have thrown an ActionNotSupported exception"); } catch ( SOAPFaultException ex) { } assertLogContains(output.toString(),"//wsa:Action","cxf"); assertTrue(output.toString().indexOf("SOAPAction=[\"cxf\"]") != -1); }

Class: org.apache.cxf.systest.ws.addr_fromwsdl.WSAFromWSDLTest

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testAddNumbers() throws Exception { ByteArrayOutputStream input=setupInLogging(); ByteArrayOutputStream output=setupOutLogging(); AddNumbersPortType port=getPort(); assertEquals(3,port.addNumbers(1,2)); String expectedOut=BASE_URI + "addNumbersRequest"; String expectedIn=BASE_URI + "addNumbersResponse"; assertTrue(output.toString().indexOf(expectedOut) != -1); assertTrue(input.toString().indexOf(expectedIn) != -1); }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testAddNumbers2() throws Exception { ByteArrayOutputStream input=setupInLogging(); ByteArrayOutputStream output=setupOutLogging(); AddNumbersPortType port=getPort(); assertEquals(3,port.addNumbers2(1,2)); String expectedOut=BASE_URI + "add2In"; String expectedIn=BASE_URI + "add2Out"; assertTrue(output.toString().indexOf(expectedOut) != -1); assertTrue(input.toString().indexOf(expectedIn) != -1); }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testAddNumbers3() throws Exception { ByteArrayOutputStream input=setupInLogging(); ByteArrayOutputStream output=setupOutLogging(); AddNumbersPortType port=getPort(); assertEquals(3,port.addNumbers3(1,2)); String expectedOut="3in"; String expectedIn="3out"; assertTrue(output.toString().indexOf(expectedOut) != -1); assertTrue(input.toString().indexOf(expectedIn) != -1); }

Class: org.apache.cxf.systest.ws.addr_wsdl.WSAPureWsdlTest

BranchVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testBasicInvocation() throws Exception { ByteArrayOutputStream input=setupInLogging(); ByteArrayOutputStream output=setupOutLogging(); Response resp; AddNumbersPortType port=getPort(); ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,"http://localhost:" + PORT + "/jaxws/add"); assertEquals(3,port.addNumbers(1,2)); String base="http://apache.org/cxf/systest/ws/addr_feature/AddNumbersPortType/"; assertLogContains(output.toString(),"//wsa:Action",base + "addNumbersRequest"); assertLogContains(input.toString(),"//wsa:Action",base + "addNumbersResponse"); resp=port.addNumbers3Async(1,2); assertEquals(3,resp.get().getReturn()); ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,"http://localhost:" + PORT + "/doesntexist"); resp=port.addNumbers3Async(1,2); try { resp.get(); } catch ( ExecutionException ex) { assertTrue("Found " + ex.getCause().getClass(),ex.getCause() instanceof IOException); Client c=ClientProxy.getClient(port); for ( Interceptor m : c.getOutInterceptors()) { if (m instanceof MAPCodec) { assertTrue(((MAPCodec)m).getUncorrelatedExchanges().isEmpty()); } } } }

InternalCallVerifier EqualityVerifier 
@Test public void testProviderEndpoint() throws Exception { String base="http://apache.org/cxf/systest/ws/addr_feature/AddNumbersPortType/"; ByteArrayOutputStream input=setupInLogging(); ByteArrayOutputStream output=setupOutLogging(); AddNumbersPortType port=getPort(); ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,"http://localhost:" + PORT + "/jaxws/add-provider"); assertEquals(3,port.addNumbers(1,2)); assertLogContains(output.toString(),"//wsa:Action",base + "addNumbersRequest"); assertLogContains(input.toString(),"//wsa:Action",base + "addNumbersResponse"); output.reset(); input.reset(); ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,"http://localhost:" + PORT + "/jaxws/add-providernows"); assertEquals(3,port.addNumbers(1,2)); assertLogContains(output.toString(),"//wsa:Action",base + "addNumbersRequest"); assertLogContains(input.toString(),"//wsa:Action",base + "addNumbersResponse"); }

UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testBasicInvocationTimeouts() throws Exception { AddNumbersPortType port=getPort(); ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,"http://localhost:" + PORT + "/jaxws/add"); HTTPConduit conduit=(HTTPConduit)((Client)port).getConduit(); conduit.getClient().setConnectionTimeout(25); conduit.getClient().setReceiveTimeout(10); try { port.addNumbersAsync(5092,25).get(); fail("should have failed"); } catch ( Exception t) { assertTrue(t.getCause().toString(),t.getCause() instanceof java.net.SocketTimeoutException); } AsyncHandler handler=new AsyncHandler(){ public void handleResponse( Response res){ synchronized (this) { notifyAll(); } } } ; synchronized (handler) { port.addNumbersAsync(5092,25,handler); handler.wait(1000); } try { ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,"http://localhost:" + PORT2 + "/jaxws/add"); port.addNumbersAsync(25,25).get(); fail("should have failed"); } catch ( Exception t) { assertTrue(t.getCause().getCause().toString(),t.getCause().getCause() instanceof java.net.ConnectException); } synchronized (handler) { port.addNumbersAsync(25,25,handler); handler.wait(1000); } MAPCodec mp=getMAPCodec((Client)port); assertEquals(0,mp.getUncorrelatedExchanges().size()); }

Class: org.apache.cxf.systest.ws.addressing.MAPTestBase

InternalCallVerifier EqualityVerifier 
@Test public void testImplicitMAPs() throws Exception { try { String greeting=greeter.greetMe("implicit1"); assertEquals("unexpected response received from service","Hello implicit1",greeting); checkVerification(); greeting=greeter.greetMe("implicit2"); assertEquals("unexpected response received from service","Hello implicit2",greeting); checkVerification(); } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

InternalCallVerifier EqualityVerifier 
@Test public void testVersioning() throws Exception { try { mapVerifier.expectedExposedAs.add(VersionTransformer.Names200408.WSA_NAMESPACE_NAME); mapVerifier.expectedExposedAs.add(VersionTransformer.Names200408.WSA_NAMESPACE_NAME); String greeting=greeter.greetMe("versioning1"); assertEquals("unexpected response received from service","Hello versioning1",greeting); checkVerification(); greeting=greeter.greetMe("versioning2"); assertEquals("unexpected response received from service","Hello versioning2",greeting); checkVerification(); } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testApplicationFault() throws Exception { try { greeter.testDocLitFault("BadRecordLitFault"); fail("expected fault from service"); } catch ( BadRecordLitFault brlf) { } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } String greeting=greeter.greetMe("intra-fault"); assertEquals("unexpected response received from service","Hello intra-fault",greeting); try { greeter.testDocLitFault("NoSuchCodeLitFault"); fail("expected NoSuchCodeLitFault"); } catch ( NoSuchCodeLitFault nsclf) { } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testExplicitMAPs() throws Exception { try { String msgId="urn:uuid:12345-" + Math.random(); Map requestContext=((BindingProvider)greeter).getRequestContext(); AddressingProperties maps=new AddressingProperties(); AttributedURIType id=ContextUtils.getAttributedURI(msgId); maps.setMessageID(id); requestContext.put(CLIENT_ADDRESSING_PROPERTIES,maps); String greeting=greeter.greetMe("explicit1"); assertEquals("unexpected response received from service","Hello explicit1",greeting); checkVerification(); try { greeter.greetMe("explicit2"); fail("expected ProtocolException on duplicate message ID"); } catch ( ProtocolException pe) { assertEquals("expected duplicate message ID failure","Duplicate Message ID " + msgId,pe.getMessage()); checkVerification(); } maps.setMessageID(null); greeting=greeter.greetMe("explicit3"); assertEquals("unexpected response received from service","Hello explicit3",greeting); } catch ( UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }

Class: org.apache.cxf.systest.ws.mex.MEXTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGet(){ JaxWsProxyFactoryBean proxyFac=new JaxWsProxyFactoryBean(); proxyFac.setBus(getStaticBus()); proxyFac.setAddress("http://localhost:" + PORT + "/jaxws/addmex"); proxyFac.getFeatures().add(new LoggingFeature()); MetadataExchange exc=proxyFac.create(MetadataExchange.class); Metadata metadata=exc.get2004(); assertNotNull(metadata); assertEquals(2,metadata.getMetadataSection().size()); assertEquals("http://schemas.xmlsoap.org/wsdl/",metadata.getMetadataSection().get(0).getDialect()); assertEquals("http://apache.org/cxf/systest/ws/addr_feature/",metadata.getMetadataSection().get(0).getIdentifier()); assertEquals("http://www.w3.org/2001/XMLSchema",metadata.getMetadataSection().get(1).getDialect()); GetMetadata body=new GetMetadata(); body.setDialect("http://www.w3.org/2001/XMLSchema"); metadata=exc.getMetadata(body); assertEquals(1,metadata.getMetadataSection().size()); assertEquals("http://www.w3.org/2001/XMLSchema",metadata.getMetadataSection().get(0).getDialect()); }

Class: org.apache.cxf.systest.ws.policy.AddressingAnonymousPolicyTest

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testUsingAddressing() throws Exception { SpringBusFactory bf=new SpringBusFactory(); bus=bf.createBus("org/apache/cxf/systest/ws/policy/addr-anon-client.xml"); BusFactory.setDefaultBus(bus); LoggingInInterceptor in=new LoggingInInterceptor(); bus.getInInterceptors().add(in); bus.getInFaultInterceptors().add(in); LoggingOutInterceptor out=new LoggingOutInterceptor(); bus.getOutInterceptors().add(out); bus.getOutFaultInterceptors().add(out); BasicGreeterService gs=new BasicGreeterService(); final Greeter greeter=gs.getGreeterPort(); updateAddressPort(greeter,PORT); LOG.fine("Created greeter client."); ConnectionHelper.setKeepAliveConnection(greeter,true); greeter.greetMeOneWay("CXF"); assertEquals("CXF",greeter.greetMe("cxf")); try { greeter.pingMe(); } catch ( PingMeFault ex) { fail("First invocation should have succeeded."); } try { greeter.pingMe(); fail("Expected PingMeFault not thrown."); } catch ( PingMeFault ex) { assertEquals(2,ex.getFaultInfo().getMajor()); assertEquals(1,ex.getFaultInfo().getMinor()); } ((Closeable)greeter).close(); }

Class: org.apache.cxf.systest.ws.policy.AddressingInlinePolicyTest

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testUsingAddressing() throws Exception { SpringBusFactory bf=new SpringBusFactory(); bus=bf.createBus("org/apache/cxf/systest/ws/policy/addr-inline-policy-old.xml"); BusFactory.setDefaultBus(bus); BasicGreeterService gs=new BasicGreeterService(); final Greeter greeter=gs.getGreeterPort(); updateAddressPort(greeter,PORT); LOG.fine("Created greeter client."); ConnectionHelper.setKeepAliveConnection(greeter,true); testInterceptors(bus); greeter.greetMeOneWay("CXF"); assertEquals("CXF",greeter.greetMe("cxf")); try { greeter.pingMe(); } catch ( PingMeFault ex) { fail("First invocation should have succeeded."); } try { greeter.pingMe(); fail("Expected PingMeFault not thrown."); } catch ( PingMeFault ex) { assertEquals(2,ex.getFaultInfo().getMajor()); assertEquals(1,ex.getFaultInfo().getMinor()); } ((Closeable)greeter).close(); }

Class: org.apache.cxf.systest.ws.policy.AddressingOptionalPolicyTest

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testNotUsingAddressing() throws Exception { SpringBusFactory bf=new SpringBusFactory(); bus=bf.createBus("org/apache/cxf/systest/ws/policy/addr-optional.xml"); BusFactory.setDefaultBus(bus); InMessageRecorder in=new InMessageRecorder(); bus.getInInterceptors().add(in); OutMessageRecorder out=new OutMessageRecorder(); bus.getOutInterceptors().add(out); bus.getExtension(PolicyEngine.class).setAlternativeSelector(new MinimalAlternativeSelector()); BasicGreeterService gs=new BasicGreeterService(); final Greeter greeter=gs.getGreeterPort(); updateAddressPort(greeter,PORT); LOG.fine("Created greeter client."); ConnectionHelper.setKeepAliveConnection(greeter,true); greeter.greetMeOneWay("CXF"); assertEquals("CXF",greeter.greetMe("cxf")); try { greeter.pingMe(); } catch ( PingMeFault ex) { fail("First invocation should have succeeded."); } try { greeter.pingMe(); fail("Expected PingMeFault not thrown."); } catch ( PingMeFault ex) { assertEquals(2,ex.getFaultInfo().getMajor()); assertEquals(1,ex.getFaultInfo().getMinor()); } MessageFlow mf=new MessageFlow(out.getOutboundMessages(),in.getInboundMessages()); for (int i=0; i < 3; i++) { mf.verifyNoHeader(RMUtils.getAddressingConstants().getMessageIDQName(),true,i); mf.verifyNoHeader(RMUtils.getAddressingConstants().getMessageIDQName(),false,i); } ((Closeable)greeter).close(); }

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testUsingAddressing() throws Exception { SpringBusFactory bf=new SpringBusFactory(); bus=bf.createBus("org/apache/cxf/systest/ws/policy/addr-optional.xml"); BusFactory.setDefaultBus(bus); InMessageRecorder in=new InMessageRecorder(); bus.getInInterceptors().add(in); OutMessageRecorder out=new OutMessageRecorder(); bus.getOutInterceptors().add(out); BasicGreeterService gs=new BasicGreeterService(); final Greeter greeter=gs.getGreeterPort(); updateAddressPort(greeter,PORT); LOG.fine("Created greeter client."); ConnectionHelper.setKeepAliveConnection(greeter,true); greeter.greetMeOneWay("CXF"); assertEquals("CXF",greeter.greetMe("cxf")); try { greeter.pingMe(); } catch ( PingMeFault ex) { fail("First invocation should have succeeded."); } try { greeter.pingMe(); fail("Expected PingMeFault not thrown."); } catch ( PingMeFault ex) { assertEquals(2,ex.getFaultInfo().getMajor()); assertEquals(1,ex.getFaultInfo().getMinor()); } MessageFlow mf=new MessageFlow(out.getOutboundMessages(),in.getInboundMessages()); for (int i=0; i < 3; i++) { mf.verifyHeader(RMUtils.getAddressingConstants().getMessageIDQName(),true,i); mf.verifyHeader(RMUtils.getAddressingConstants().getMessageIDQName(),false,i); } ((Closeable)greeter).close(); }

Class: org.apache.cxf.systest.ws.policy.AddressingPolicy0705Test

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testUsingAddressing() throws Exception { SpringBusFactory bf=new SpringBusFactory(); bus=bf.createBus("org/apache/cxf/systest/ws/policy/addr0705.xml"); BusFactory.setDefaultBus(bus); LoggingInInterceptor in=new LoggingInInterceptor(); bus.getInInterceptors().add(in); bus.getInFaultInterceptors().add(in); LoggingOutInterceptor out=new LoggingOutInterceptor(); bus.getOutInterceptors().add(out); bus.getOutFaultInterceptors().add(out); BasicGreeterService gs=new BasicGreeterService(); final Greeter greeter=gs.getGreeterPort(); updateAddressPort(greeter,PORT); LOG.fine("Created greeter client."); ConnectionHelper.setKeepAliveConnection(greeter,true); assertEquals("CXF",greeter.greetMe("cxf")); try { greeter.pingMe(); } catch ( PingMeFault ex) { fail("First invocation should have succeeded."); } try { greeter.pingMe(); fail("Expected PingMeFault not thrown."); } catch ( PingMeFault ex) { assertEquals(2,ex.getFaultInfo().getMajor()); assertEquals(1,ex.getFaultInfo().getMinor()); } ((Closeable)greeter).close(); }

Class: org.apache.cxf.systest.ws.policy.AddressingPolicyExternalAttachmentWsdl11Test

InternalCallVerifier EqualityVerifier 
@Test public void testUsingAddressing() throws Exception { SpringBusFactory bf=new SpringBusFactory(); bus=bf.createBus("org/apache/cxf/systest/ws/policy/addr-wsdl11.xml"); BusFactory.setDefaultBus(bus); LoggingInInterceptor in=new LoggingInInterceptor(); bus.getInInterceptors().add(in); bus.getInFaultInterceptors().add(in); LoggingOutInterceptor out=new LoggingOutInterceptor(); bus.getOutInterceptors().add(out); bus.getOutFaultInterceptors().add(out); BasicGreeterService gs=new BasicGreeterService(); final Greeter greeter=gs.getGreeterPort(); updateAddressPort(greeter,PORT); LOG.fine("Created greeter client."); ConnectionHelper.setKeepAliveConnection(greeter,true); assertEquals("CXF",greeter.greetMe("cxf")); ((Closeable)greeter).close(); }

Class: org.apache.cxf.systest.ws.policy.AddressingPolicyTest

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testUsingAddressing() throws Exception { SpringBusFactory bf=new SpringBusFactory(); bus=bf.createBus("org/apache/cxf/systest/ws/policy/addr.xml"); BusFactory.setDefaultBus(bus); LoggingInInterceptor in=new LoggingInInterceptor(); bus.getInInterceptors().add(in); bus.getInFaultInterceptors().add(in); LoggingOutInterceptor out=new LoggingOutInterceptor(); bus.getOutInterceptors().add(out); bus.getOutFaultInterceptors().add(out); BasicGreeterService gs=new BasicGreeterService(); final Greeter greeter=gs.getGreeterPort(); updateAddressPort(greeter,PORT); LOG.fine("Created greeter client."); ConnectionHelper.setKeepAliveConnection(greeter,true); assertEquals("CXF",greeter.greetMe("cxf")); try { greeter.pingMe(); } catch ( PingMeFault ex) { fail("First invocation should have succeeded."); } try { greeter.pingMe(); fail("Expected PingMeFault not thrown."); } catch ( PingMeFault ex) { assertEquals(2,ex.getFaultInfo().getMajor()); assertEquals(1,ex.getFaultInfo().getMinor()); } ((Closeable)greeter).close(); }

Class: org.apache.cxf.systest.ws.policy.HTTPClientPolicyTest

APIUtilityVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testUsingHTTPClientPolicies() throws Exception { SpringBusFactory bf=new SpringBusFactory(); bus=bf.createBus(POLICY_ENGINE_ENABLED_CFG); BusFactory.setDefaultBus(bus); LoggingInInterceptor in=new LoggingInInterceptor(); bus.getInInterceptors().add(in); bus.getInFaultInterceptors().add(in); LoggingOutInterceptor out=new LoggingOutInterceptor(); bus.getOutInterceptors().add(out); bus.getOutFaultInterceptors().add(out); URL url=HTTPClientPolicyTest.class.getResource("http_client_greeter.wsdl"); BasicGreeterService gs=new BasicGreeterService(url,GREETER_QNAME); final Greeter greeter=gs.getGreeterPort(); updateAddressPort(greeter,PORT); LOG.fine("Created greeter client."); try { greeter.sayHi(); fail("Did not receive expected PolicyException."); } catch ( WebServiceException wex) { PolicyException ex=(PolicyException)wex.getCause(); assertEquals("INCOMPATIBLE_HTTPCLIENTPOLICY_ASSERTIONS",ex.getCode()); } greeter.greetMeOneWay("CXF"); assertEquals("CXF",greeter.greetMe("cxf")); try { greeter.greetMe("cxf"); fail("Didn't get the exception"); } catch ( Exception ex) { assertTrue(ex.getCause().getClass().getName(),ex.getCause() instanceof SocketTimeoutException); } try { greeter.pingMe(); fail("Expected PingMeFault not thrown."); } catch ( PingMeFault ex) { assertEquals(2,ex.getFaultInfo().getMajor()); assertEquals(1,ex.getFaultInfo().getMinor()); } ((Closeable)greeter).close(); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testHTTPClientPolicyViaFeature() throws Exception { SpringBusFactory bf=new SpringBusFactory(); bus=bf.createBus(POLICY_VIA_FEATURE_CFG); BusFactory.setDefaultBus(bus); URL url=HTTPClientPolicyTest.class.getResource("bare_greeter.wsdl"); BasicGreeterService gs=new BasicGreeterService(url,GREETER_QNAME); final Greeter greeter=gs.getGreeterPort(); LOG.fine("Created greeter client."); updateAddressPort(greeter,PORT); greeter.greetMeOneWay("CXF"); HTTPConduit c=(HTTPConduit)(ClientProxy.getClient(greeter).getConduit()); assertNotNull("expected HTTPConduit",c); assertNotNull("expected DecoupledEndpoint",c.getClient().getDecoupledEndpoint()); assertEquals("unexpected DecoupledEndpoint","http://localhost:9909/decoupled_endpoint",c.getClient().getDecoupledEndpoint()); ((Closeable)greeter).close(); }

Class: org.apache.cxf.systest.ws.policy.HTTPServerPolicyTest

APIUtilityVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testUsingHTTPServerPolicies() throws Exception { SpringBusFactory bf=new SpringBusFactory(); Bus bus=bf.createBus(); BasicGreeterService gs=new BasicGreeterService(); final Greeter greeter=gs.getGreeterPort(); updateAddressPort(greeter,PORT); LoggingInInterceptor in=new LoggingInInterceptor(); LoggingOutInterceptor out=new LoggingOutInterceptor(); bus.getInInterceptors().add(in); bus.getOutInterceptors().add(out); LOG.fine("Created greeter client."); try { greeter.sayHi(); fail("Did not receive expected Exception."); } catch ( WebServiceException wse) { SoapFault sf=(SoapFault)wse.getCause(); assertEquals("Server",sf.getFaultCode().getLocalPart()); String text=sf.getMessage(); assertTrue(text.contains("{http://cxf.apache.org/transports/http/configuration}server")); } assertEquals("CXF",greeter.greetMe("cxf")); try { greeter.pingMe(); fail("Expected PingMeFault not thrown."); } catch ( PingMeFault ex) { assertEquals(2,ex.getFaultInfo().getMajor()); assertEquals(1,ex.getFaultInfo().getMinor()); } ((Closeable)greeter).close(); }

Class: org.apache.cxf.systest.ws.policy.NestedAddressingPolicyTest

InternalCallVerifier EqualityVerifier 
@Test public void greetMeWSA() throws Exception { SpringBusFactory bf=new SpringBusFactory(); bus=bf.createBus(); BusFactory.setDefaultBus(bus); BasicGreeterService gs=new BasicGreeterService(); final Greeter greeter=gs.getGreeterPort(); updateAddressPort(greeter,PORT); LoggingInInterceptor in=new LoggingInInterceptor(); LoggingOutInterceptor out=new LoggingOutInterceptor(); MAPCodec mapCodec=new MAPCodec(); MAPAggregatorImpl mapAggregator=new MAPAggregatorImpl(); bus.getInInterceptors().add(in); bus.getInInterceptors().add(mapCodec); bus.getInInterceptors().add(mapAggregator); bus.getOutInterceptors().add(out); bus.getOutInterceptors().add(mapCodec); bus.getOutInterceptors().add(mapAggregator); String s=greeter.greetMe("mytest"); assertEquals("MYTEST",s); ((Closeable)greeter).close(); }

Class: org.apache.cxf.systest.ws.policy.RM10PolicyWsdlTest

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testUsingRM() throws Exception { setUpBus(PORT); ReliableGreeterService gs=new ReliableGreeterService(); Greeter greeter=gs.getGreeterPort(); updateAddressPort(greeter,PORT); LOG.fine("Created greeter client."); ConnectionHelper.setKeepAliveConnection(greeter,true); assertEquals("CXF",greeter.greetMe("cxf")); greeter.greetMeOneWay("CXF"); try { greeter.pingMe(); } catch ( PingMeFault ex) { fail("First invocation should have succeeded."); } try { greeter.pingMe(); fail("Expected PingMeFault not thrown."); } catch ( PingMeFault ex) { assertEquals(2,ex.getFaultInfo().getMajor()); assertEquals(1,ex.getFaultInfo().getMinor()); } MessageRecorder mr=new MessageRecorder(outRecorder,inRecorder); mr.awaitMessages(5,4,5000); MessageFlow mf=new MessageFlow(outRecorder.getOutboundMessages(),inRecorder.getInboundMessages(),"http://schemas.xmlsoap.org/ws/2004/08/addressing","http://schemas.xmlsoap.org/ws/2005/02/rm"); mf.verifyMessages(5,true); String[] expectedActions=new String[]{RM10Constants.INSTANCE.getCreateSequenceAction(),GREETME_ACTION,GREETMEONEWAY_ACTION,PINGME_ACTION,PINGME_ACTION}; mf.verifyActions(expectedActions,true); mf.verifyMessageNumbers(new String[]{null,"1","2","3","4"},true); mf.verifyLastMessage(new boolean[]{false,false,false,false,false},true); mf.verifyAcknowledgements(new boolean[]{false,false,true,false,true},true); mf.verifyMessages(4,false); expectedActions=new String[]{RM10Constants.INSTANCE.getCreateSequenceResponseAction(),GREETME_RESPONSE_ACTION,PINGME_RESPONSE_ACTION,GREETER_FAULT_ACTION}; mf.verifyActions(expectedActions,false); mf.verifyMessageNumbers(new String[]{null,"1","2","3"},false); mf.verifyLastMessage(new boolean[]{false,false,false,false},false); mf.verifyAcknowledgements(new boolean[]{false,true,true,true},false); ((Closeable)greeter).close(); }

Class: org.apache.cxf.systest.ws.policy.RM12PolicyWsdlTest

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testUsingRM12() throws Exception { setUpBus(PORT); Reliable12GreeterService gs=new Reliable12GreeterService(); Greeter greeter=gs.getGreeterPort(); updateAddressPort(greeter,PORT); ConnectionHelper.setKeepAliveConnection(greeter,true); LOG.fine("Created greeter client."); assertEquals("CXF",greeter.greetMe("cxf")); greeter.greetMeOneWay("CXF"); try { greeter.pingMe(); } catch ( PingMeFault ex) { fail("First invocation should have succeeded."); } try { greeter.pingMe(); fail("Expected PingMeFault not thrown."); } catch ( PingMeFault ex) { assertEquals(2,ex.getFaultInfo().getMajor()); assertEquals(1,ex.getFaultInfo().getMinor()); } MessageRecorder mr=new MessageRecorder(outRecorder,inRecorder); mr.awaitMessages(5,4,5000); MessageFlow mf=new MessageFlow(outRecorder.getOutboundMessages(),inRecorder.getInboundMessages(),"http://www.w3.org/2005/08/addressing","http://docs.oasis-open.org/ws-rx/wsrm/200702"); mf.verifyMessages(5,true); String[] expectedActions=new String[]{RM11Constants.INSTANCE.getCreateSequenceAction(),GREETME_ACTION,GREETMEONEWAY_ACTION,PINGME_ACTION,PINGME_ACTION}; mf.verifyActions(expectedActions,true); mf.verifyMessageNumbers(new String[]{null,"1","2","3","4"},true); mf.verifyLastMessage(new boolean[]{false,false,false,false,false},true); mf.verifyAcknowledgements(new boolean[]{false,false,true,false,true},true); mf.verifyMessages(4,false); expectedActions=new String[]{RM11Constants.INSTANCE.getCreateSequenceResponseAction(),GREETME_RESPONSE_ACTION,PINGME_RESPONSE_ACTION,GREETER_FAULT_ACTION}; mf.verifyActions(expectedActions,false); mf.verifyMessageNumbers(new String[]{null,"1","2","3"},false); mf.verifyLastMessage(new boolean[]{false,false,false,false},false); mf.verifyAcknowledgements(new boolean[]{false,true,true,true},false); ((Closeable)greeter).close(); }

Class: org.apache.cxf.systest.ws.policy.RMPolicyTest

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testUsingRM() throws Exception { SpringBusFactory bf=new SpringBusFactory(); bus=bf.createBus("org/apache/cxf/systest/ws/policy/rm.xml"); BusFactory.setDefaultBus(bus); OutMessageRecorder outRecorder=new OutMessageRecorder(); bus.getOutInterceptors().add(outRecorder); InMessageRecorder inRecorder=new InMessageRecorder(); bus.getInInterceptors().add(inRecorder); BasicGreeterService gs=new BasicGreeterService(); final Greeter greeter=gs.getGreeterPort(); updateAddressPort(greeter,PORT); LOG.fine("Created greeter client."); ConnectionHelper.setKeepAliveConnection(greeter,true); assertEquals("CXF",greeter.greetMe("cxf")); greeter.greetMeOneWay("CXF"); try { greeter.pingMe(); } catch ( PingMeFault ex) { fail("First invocation should have succeeded."); } try { greeter.pingMe(); fail("Expected PingMeFault not thrown."); } catch ( PingMeFault ex) { assertEquals(2,ex.getFaultInfo().getMajor()); assertEquals(1,ex.getFaultInfo().getMinor()); } MessageRecorder mr=new MessageRecorder(outRecorder,inRecorder); mr.awaitMessages(5,4,5000); MessageFlow mf=new MessageFlow(outRecorder.getOutboundMessages(),inRecorder.getInboundMessages(),Names200408.WSA_NAMESPACE_NAME,RM10Constants.NAMESPACE_URI); mf.verifyMessages(5,true); String[] expectedActions=new String[]{RM10Constants.INSTANCE.getCreateSequenceAction(),GREETME_ACTION,GREETMEONEWAY_ACTION,PINGME_ACTION,PINGME_ACTION}; mf.verifyActions(expectedActions,true); mf.verifyMessageNumbers(new String[]{null,"1","2","3","4"},true); mf.verifyLastMessage(new boolean[]{false,false,false,false,false},true); mf.verifyAcknowledgements(new boolean[]{false,false,true,false,true},true); mf.verifyMessages(4,false); expectedActions=new String[]{RM10Constants.INSTANCE.getCreateSequenceResponseAction(),GREETME_RESPONSE_ACTION,PINGME_RESPONSE_ACTION,GREETER_FAULT_ACTION}; mf.verifyActions(expectedActions,false); mf.verifyMessageNumbers(new String[]{null,"1","2","3"},false); mf.verifyLastMessage(new boolean[]{false,false,false,false},false); mf.verifyAcknowledgements(new boolean[]{false,true,true,true},false); ((Closeable)greeter).close(); }

Class: org.apache.cxf.systest.ws.policy.handler.PolicyHandlerFaultResponseTest

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testFaultResponse() throws Exception { String address="http://localhost:" + PORT + "/policytest"; URL wsdlURL=new URL(address + "?wsdl"); Service service=Service.create(wsdlURL,serviceName); service.addPort(new QName("http://handler.policy.ws.systest.cxf.apache.org/","HelloPolicyServicePort"),SOAPBinding.SOAP11HTTP_BINDING,address); HelloService port=service.getPort(new QName("http://handler.policy.ws.systest.cxf.apache.org/","HelloPolicyServicePort"),HelloService.class); Map context=((BindingProvider)port).getRequestContext(); context.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,address); context.put(SecurityConstants.CALLBACK_HANDLER,new CommonPasswordCallback()); context.put(SecurityConstants.SIGNATURE_PROPERTIES,"alice.properties"); context.put(SecurityConstants.SIGNATURE_USERNAME,"alice"); try { port.checkHello("input"); fail("Exception is expected"); } catch ( MyFault e) { assertEquals("Fault is not expected","myMessage",e.getMessage()); } }

Class: org.apache.cxf.systest.ws.rm.DecoupledBareTest

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDecoupled() throws Exception { SpringBusFactory bf=new SpringBusFactory(); bus=bf.createBus("/org/apache/cxf/systest/ws/rm/decoupled_bare.xml"); BusFactory.setDefaultBus(bus); SOAPServiceAddressingDocLitBare service=new SOAPServiceAddressingDocLitBare(); assertNotNull(service); DocLitBare greeter=service.getSoapPort(); updateAddressPort(greeter,PORT); ((BindingProvider)greeter).getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED,Boolean.TRUE); ConnectionHelper.setKeepAliveConnection(greeter,true); BareDocumentResponse bareres=greeter.testDocLitBare("MySimpleDocument"); assertNotNull("no response for operation testDocLitBare",bareres); assertEquals("CXF",bareres.getCompany()); assertTrue(bareres.getId() == 1); }

Class: org.apache.cxf.systest.ws.rm.DecoupledClientServerTest

InternalCallVerifier EqualityVerifier 
@Test public void testDecoupled() throws Exception { SpringBusFactory bf=new SpringBusFactory(); bus=bf.createBus("/org/apache/cxf/systest/ws/rm/decoupled.xml"); BusFactory.setDefaultBus(bus); LoggingInInterceptor in=new LoggingInInterceptor(); bus.getInInterceptors().add(in); bus.getInFaultInterceptors().add(in); LoggingOutInterceptor out=new LoggingOutInterceptor(); bus.getOutInterceptors().add(out); bus.getOutFaultInterceptors().add(out); GreeterService gs=new GreeterService(); final Greeter greeter=gs.getGreeterPort(); updateAddressPort(greeter,PORT); ((BindingProvider)greeter).getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED,Boolean.TRUE); LOG.fine("Created greeter client."); ConnectionHelper.setKeepAliveConnection(greeter,true); class TwowayThread extends Thread { String response; @Override public void run(){ response=greeter.greetMe("twoway"); } } TwowayThread t=new TwowayThread(); t.start(); long wait=3000; while (wait > 0) { long start=System.currentTimeMillis(); try { Thread.sleep(wait); } catch ( InterruptedException ex) { } wait-=System.currentTimeMillis() - start; } greeter.greetMeOneWay("oneway"); t.join(); assertEquals("Unexpected response to twoway request","oneway",t.response); }

Class: org.apache.cxf.systest.ws.rm.ProtocolVariationsTest

InternalCallVerifier EqualityVerifier 
@Test public void testDefaultDecoupled() throws Exception { init("org/apache/cxf/systest/ws/rm/rminterceptors.xml",true); assertEquals("ONE",greeter.greetMe("one")); assertEquals("TWO",greeter.greetMe("two")); assertEquals("THREE",greeter.greetMe("three")); verifyTwowayNonAnonymous(Names200408.WSA_NAMESPACE_NAME,RM10Constants.INSTANCE); }

InternalCallVerifier EqualityVerifier 
@Test public void testDefault() throws Exception { init("org/apache/cxf/systest/ws/rm/rminterceptors.xml",false); assertEquals("ONE",greeter.greetMe("one")); assertEquals("TWO",greeter.greetMe("two")); assertEquals("THREE",greeter.greetMe("three")); verifyTwowayNonAnonymous(Names200408.WSA_NAMESPACE_NAME,RM10Constants.INSTANCE); }

InternalCallVerifier EqualityVerifier 
@Test public void testRM11() throws Exception { init("org/apache/cxf/systest/ws/rm/rminterceptors.xml",false); Client client=ClientProxy.getClient(greeter); client.getRequestContext().put(RMManager.WSRM_VERSION_PROPERTY,RM11Constants.NAMESPACE_URI); client.getRequestContext().put(RMManager.WSRM_WSA_VERSION_PROPERTY,Names.WSA_NAMESPACE_NAME); assertEquals("ONE",greeter.greetMe("one")); assertEquals("TWO",greeter.greetMe("two")); assertEquals("THREE",greeter.greetMe("three")); verifyTwowayNonAnonymous(Names.WSA_NAMESPACE_NAME,RM11Constants.INSTANCE); }

InternalCallVerifier EqualityVerifier 
@Test public void testRM10WSA200408Decoupled() throws Exception { init("org/apache/cxf/systest/ws/rm/rminterceptors.xml",true); Client client=ClientProxy.getClient(greeter); client.getRequestContext().put(RMManager.WSRM_WSA_VERSION_PROPERTY,Names200408.WSA_NAMESPACE_NAME); assertEquals("ONE",greeter.greetMe("one")); assertEquals("TWO",greeter.greetMe("two")); assertEquals("THREE",greeter.greetMe("three")); verifyTwowayNonAnonymous(Names200408.WSA_NAMESPACE_NAME,RM10Constants.INSTANCE); }

InternalCallVerifier EqualityVerifier 
@Test public void testRM10WSA200408() throws Exception { init("org/apache/cxf/systest/ws/rm/rminterceptors.xml",false); Client client=ClientProxy.getClient(greeter); client.getRequestContext().put(RMManager.WSRM_WSA_VERSION_PROPERTY,Names200408.WSA_NAMESPACE_NAME); assertEquals("ONE",greeter.greetMe("one")); assertEquals("TWO",greeter.greetMe("two")); assertEquals("THREE",greeter.greetMe("three")); verifyTwowayNonAnonymous(Names200408.WSA_NAMESPACE_NAME,RM10Constants.INSTANCE); }

InternalCallVerifier EqualityVerifier 
@Test public void testRM11Decoupled() throws Exception { init("org/apache/cxf/systest/ws/rm/rminterceptors.xml",true); Client client=ClientProxy.getClient(greeter); client.getRequestContext().put(RMManager.WSRM_VERSION_PROPERTY,RM11Constants.NAMESPACE_URI); client.getRequestContext().put(RMManager.WSRM_WSA_VERSION_PROPERTY,Names.WSA_NAMESPACE_NAME); assertEquals("ONE",greeter.greetMe("one")); assertEquals("TWO",greeter.greetMe("two")); assertEquals("THREE",greeter.greetMe("three")); verifyTwowayNonAnonymous(Names.WSA_NAMESPACE_NAME,RM11Constants.INSTANCE); }

InternalCallVerifier EqualityVerifier 
@Test public void testRM10WSA15() throws Exception { init("org/apache/cxf/systest/ws/rm/rminterceptors.xml",false); Client client=ClientProxy.getClient(greeter); client.getRequestContext().put(RMManager.WSRM_WSA_VERSION_PROPERTY,Names.WSA_NAMESPACE_NAME); assertEquals("ONE",greeter.greetMe("one")); assertEquals("TWO",greeter.greetMe("two")); assertEquals("THREE",greeter.greetMe("three")); verifyTwowayNonAnonymous(Names.WSA_NAMESPACE_NAME,RM10Constants.INSTANCE); }

InternalCallVerifier EqualityVerifier 
@Test public void testRM10WSA15Decoupled() throws Exception { init("org/apache/cxf/systest/ws/rm/rminterceptors.xml",true); Client client=ClientProxy.getClient(greeter); client.getRequestContext().put(RMManager.WSRM_WSA_VERSION_PROPERTY,Names.WSA_NAMESPACE_NAME); assertEquals("ONE",greeter.greetMe("one")); assertEquals("TWO",greeter.greetMe("two")); assertEquals("THREE",greeter.greetMe("three")); verifyTwowayNonAnonymous(Names.WSA_NAMESPACE_NAME,RM10Constants.INSTANCE); }

Class: org.apache.cxf.systest.ws.rm.RobustServiceAtMostOnceTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testRobustAtMostOnceWithSlowProcessing() throws Exception { LOG.fine("Creating greeter client"); SpringBusFactory bf=new SpringBusFactory(); bus=bf.createBus("/org/apache/cxf/systest/ws/rm/seqlength1.xml"); RMManager manager=bus.getExtension(RMManager.class); manager.getConfiguration().setBaseRetransmissionInterval(new Long(3000)); BusFactory.setDefaultBus(bus); GreeterService gs=new GreeterService(); greeter=gs.getGreeterPort(); updateAddressPort(greeter,PORT); LOG.fine("Invoking greeter"); greeter.greetMeOneWay("one"); Thread.sleep(10000); assertEquals("invoked too many times",1,serverGreeter.getCount()); assertTrue("still in retransmission",manager.getRetransmissionQueue().isEmpty()); }

Class: org.apache.cxf.systest.ws.rm.RobustServiceWithFaultTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testRobustWithSomeFaults() throws Exception { LOG.fine("Creating greeter client"); SpringBusFactory bf=new SpringBusFactory(); bus=bf.createBus("/org/apache/cxf/systest/ws/rm/seqlength1.xml"); RMManager manager=bus.getExtension(RMManager.class); manager.getConfiguration().setBaseRetransmissionInterval(new Long(5000)); BusFactory.setDefaultBus(bus); GreeterService gs=new GreeterService(); greeter=gs.getGreeterPort(); updateAddressPort(greeter,PORT); LOG.fine("Invoking greeter"); greeter.greetMeOneWay("one"); Thread.sleep(3000); assertEquals("not invoked once",1,serverGreeter.getCount()); assertTrue("still in retransmission",manager.getRetransmissionQueue().isEmpty()); LOG.fine("Invoking greeter and raising a fault"); serverGreeter.setThrowAlways(true); greeter.greetMeOneWay("two"); Thread.sleep(3000); assertEquals("not invoked once",1,serverGreeter.getCount()); assertTrue("still in retransmission",manager.getRetransmissionQueue().isEmpty()); LOG.fine("Invoking robust greeter and raising a fault"); robustSetter.setRobust(true); greeter.greetMeOneWay("three"); Thread.sleep(3000); assertEquals("not invoked once",1,serverGreeter.getCount()); assertFalse("no message in retransmission",manager.getRetransmissionQueue().isEmpty()); LOG.fine("Stop raising a fault and let the retransmission succeeds"); serverGreeter.setThrowAlways(false); Thread.sleep(8000); assertEquals("not invoked twice",2,serverGreeter.getCount()); assertTrue("still in retransmission",manager.getRetransmissionQueue().isEmpty()); }

Class: org.apache.cxf.systest.ws.rm.SequenceTest

APIUtilityVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testInactivityTimeout() throws Exception { init("org/apache/cxf/systest/ws/rm/inactivity-timeout.xml"); greeter.greetMe("one"); try { Thread.sleep(500); } catch ( InterruptedException ex) { } try { greeter.greetMe("two"); fail("Expected fault."); } catch ( WebServiceException ex) { SoapFault sf=(SoapFault)ex.getCause(); assertEquals("Unexpected fault code.",Soap11.getInstance().getSender(),sf.getFaultCode()); assertNull("Unexpected sub code.",sf.getSubCode()); assertTrue("Unexpected reason.",sf.getReason().endsWith("is not a known Sequence identifier.")); } awaitMessages(3,3,5000); MessageFlow mf=new MessageFlow(outRecorder.getOutboundMessages(),inRecorder.getInboundMessages(),Names200408.WSA_NAMESPACE_NAME,RM10Constants.NAMESPACE_URI); String[] expectedActions=new String[3]; expectedActions[0]=RM10Constants.CREATE_SEQUENCE_ACTION; for (int i=1; i < expectedActions.length; i++) { expectedActions[i]=GREETME_ACTION; } mf.verifyActions(expectedActions,true); mf.verifyMessageNumbers(new String[]{null,"1","2"},true); mf.verifyLastMessage(new boolean[3],true); mf.verifyAcknowledgements(new boolean[]{false,false,false},true); mf.verifyMessages(3,false); expectedActions=new String[]{RM10Constants.CREATE_SEQUENCE_RESPONSE_ACTION,GREETME_RESPONSE_ACTION,RM10_GENERIC_FAULT_ACTION}; mf.verifyActions(expectedActions,false); mf.verifyMessageNumbers(new String[]{null,"1",null},false); mf.verifyAcknowledgements(new boolean[]{false,true,false},false); mf.verifySequenceFault(RM10Constants.UNKNOWN_SEQUENCE_FAULT_QNAME,false,2); }

InternalCallVerifier EqualityVerifier 
@Test public void testCreateSequenceAfterSequenceExpiration() throws Exception { init("org/apache/cxf/systest/ws/rm/expire-fast-seq.xml",true); RMManager manager=greeterBus.getExtension(RMManager.class); assertEquals("Unexpected expiration",DatatypeFactory.createDuration("PT5S"),manager.getSourcePolicy().getSequenceExpiration()); greeter.greetMeOneWay("one"); greeter.greetMeOneWay("two"); Thread.sleep(8000); awaitMessages(3,2,5000); MessageFlow mf=new MessageFlow(outRecorder.getOutboundMessages(),inRecorder.getInboundMessages(),Names200408.WSA_NAMESPACE_NAME,RM10Constants.NAMESPACE_URI); mf.verifyMessages(3,true); verifyCreateSequenceAction(0,"PT5S",mf,true); String[] expectedActions=new String[]{RM10Constants.INSTANCE.getCreateSequenceAction(),GREETMEONEWAY_ACTION,GREETMEONEWAY_ACTION}; mf.verifyActions(expectedActions,true); mf.verifyMessageNumbers(new String[]{null,"1","2"},true); mf.verifyAcknowledgementRange(1,2); outRecorder.getOutboundMessages().clear(); inRecorder.getInboundMessages().clear(); greeter.greetMeOneWay("three"); awaitMessages(2,2,5000); mf=new MessageFlow(outRecorder.getOutboundMessages(),inRecorder.getInboundMessages(),Names200408.WSA_NAMESPACE_NAME,RM10Constants.NAMESPACE_URI); mf.verifyMessages(2,true); verifyCreateSequenceAction(0,"PT5S",mf,true); expectedActions=new String[]{RM10Constants.INSTANCE.getCreateSequenceAction(),GREETMEONEWAY_ACTION}; mf.verifyActions(expectedActions,true); mf.verifyMessageNumbers(new String[]{null,"1"},true); mf.verifyMessages(2,false); expectedActions=new String[]{RM10Constants.INSTANCE.getCreateSequenceResponseAction(),RM10Constants.INSTANCE.getSequenceAckAction()}; mf.verifyActions(expectedActions,false); mf.purge(); assertEquals(0,outRecorder.getOutboundMessages().size()); assertEquals(0,inRecorder.getInboundMessages().size()); }

InternalCallVerifier EqualityVerifier 
@Test public void testTwowayNonAnonymousMaximumSequenceLength2() throws Exception { init("org/apache/cxf/systest/ws/rm/seqlength10.xml",true); RMManager manager=greeterBus.getExtension(RMManager.class); assertEquals("Unexpected maximum sequence length.",10,manager.getSourcePolicy().getSequenceTerminationPolicy().getMaxLength()); manager.getSourcePolicy().getSequenceTerminationPolicy().setMaxLength(2); greeter.greetMe("one"); greeter.greetMe("two"); greeter.greetMe("three"); awaitMessages(7,6,5000); MessageFlow mf=new MessageFlow(outRecorder.getOutboundMessages(),inRecorder.getInboundMessages(),Names200408.WSA_NAMESPACE_NAME,RM10Constants.NAMESPACE_URI); mf.verifyMessages(7,true); String[] expectedActions=new String[]{RM10Constants.CREATE_SEQUENCE_ACTION,GREETME_ACTION,GREETME_ACTION,RM10Constants.TERMINATE_SEQUENCE_ACTION,RM10Constants.SEQUENCE_ACKNOWLEDGMENT_ACTION,RM10Constants.CREATE_SEQUENCE_ACTION,GREETME_ACTION}; mf.verifyActions(expectedActions,true); mf.verifyMessageNumbers(new String[]{null,"1","2",null,null,null,"1"},true); mf.verifyLastMessage(new boolean[]{false,false,true,false,false,false,false},true); mf.verifyAcknowledgements(new boolean[]{false,false,true,false,true,false,false},true); mf.verifyMessages(6,false); expectedActions=new String[]{RM10Constants.CREATE_SEQUENCE_RESPONSE_ACTION,GREETME_RESPONSE_ACTION,GREETME_RESPONSE_ACTION,RM10Constants.TERMINATE_SEQUENCE_ACTION,RM10Constants.CREATE_SEQUENCE_RESPONSE_ACTION,GREETME_RESPONSE_ACTION}; mf.verifyActions(expectedActions,false); mf.verifyMessageNumbers(new String[]{null,"1","2",null,null,"1"},false); boolean[] expected=new boolean[6]; expected[2]=true; mf.verifyLastMessage(expected,false); expected[1]=true; expected[5]=true; mf.verifyAcknowledgements(expected,false); }

APIUtilityVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testUnknownSequence() throws Exception { init("org/apache/cxf/systest/ws/rm/rminterceptors.xml"); class SequenceIdInterceptor extends AbstractPhaseInterceptor { SequenceIdInterceptor(){ super(Phase.PRE_STREAM); } public void handleMessage( Message m){ RMProperties rmps=RMContextUtils.retrieveRMProperties(m,true); if (null != rmps && null != rmps.getSequence()) { rmps.getSequence().getIdentifier().setValue("UNKNOWN"); } } } greeterBus.getOutInterceptors().add(new SequenceIdInterceptor()); RMManager manager=greeterBus.getExtension(RMManager.class); manager.getConfiguration().setBaseRetransmissionInterval(new Long(2000)); try { greeter.greetMe("one"); fail("Expected fault."); } catch ( WebServiceException ex) { SoapFault sf=(SoapFault)ex.getCause(); assertEquals("Unexpected fault code.",Soap11.getInstance().getSender(),sf.getFaultCode()); assertNull("Unexpected sub code.",sf.getSubCode()); assertTrue("Unexpected reason.",sf.getReason().endsWith("is not a known Sequence identifier.")); } MessageFlow mf=new MessageFlow(outRecorder.getOutboundMessages(),inRecorder.getInboundMessages(),Names200408.WSA_NAMESPACE_NAME,RM10Constants.NAMESPACE_URI); mf.verifySequenceFault(RM10Constants.UNKNOWN_SEQUENCE_FAULT_QNAME,false,1); String[] expectedActions=new String[3]; expectedActions=new String[]{RM10Constants.CREATE_SEQUENCE_RESPONSE_ACTION,RM10_GENERIC_FAULT_ACTION}; mf.verifyActions(expectedActions,false); }

InternalCallVerifier EqualityVerifier 
@Test public void testTwowayNonAnonymousProvider() throws Exception { init("org/apache/cxf/systest/ws/rm/rminterceptors_provider.xml",true); assertEquals("ONE",greeter.greetMe("one")); assertEquals("TWO",greeter.greetMe("two")); assertEquals("THREE",greeter.greetMe("three")); }

InternalCallVerifier EqualityVerifier 
@Test public void testTwowayAnonymousSequenceLength1() throws Exception { init("org/apache/cxf/systest/ws/rm/seqlength1.xml"); String v=greeter.greetMe("once"); assertEquals("Unexpected response","ONCE",v); awaitMessages(4,3); MessageFlow mf=new MessageFlow(outRecorder.getOutboundMessages(),inRecorder.getInboundMessages(),Names200408.WSA_NAMESPACE_NAME,RM10Constants.NAMESPACE_URI); mf.verifyMessages(4,true); String[] expectedActions=new String[]{RM10Constants.CREATE_SEQUENCE_ACTION,GREETME_ACTION,RM10Constants.TERMINATE_SEQUENCE_ACTION,RM10Constants.SEQUENCE_ACKNOWLEDGMENT_ACTION}; mf.verifyActions(expectedActions,true); mf.verifyMessageNumbers(new String[]{null,"1",null,null},true); mf.verifyLastMessage(new boolean[]{false,true,false,false},true); mf.verifyAcknowledgements(new boolean[]{false,false,false,true},true); mf.verifyMessages(3,false); expectedActions=new String[]{RM10Constants.CREATE_SEQUENCE_RESPONSE_ACTION,GREETME_RESPONSE_ACTION,RM10Constants.TERMINATE_SEQUENCE_ACTION}; mf.verifyActions(expectedActions,false); mf.verifyMessageNumbers(new String[]{null,"1",null},false); mf.verifyLastMessage(new boolean[]{false,true,false},false); mf.verifyAcknowledgements(new boolean[]{false,true,false},false); }

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testCreateSequenceRefused() throws Exception { init("org/apache/cxf/systest/ws/rm/limit-seqs.xml"); RMManager manager=greeterBus.getExtension(RMManager.class); assertEquals("Unexpected maximum sequence count.",1,manager.getDestinationPolicy().getMaxSequences()); greeter.greetMe("one"); Closeable oldGreeter=(Closeable)greeter; initProxy(false,null); try { greeter.greetMe("two"); fail("Expected fault."); } catch ( WebServiceException ex) { } MessageFlow mf=new MessageFlow(outRecorder.getOutboundMessages(),inRecorder.getInboundMessages(),Names200408.WSA_NAMESPACE_NAME,RM10Constants.NAMESPACE_URI); mf.verifySequenceFault(RM10Constants.CREATE_SEQUENCE_REFUSED_FAULT_QNAME,false,2); String[] expectedActions=new String[3]; expectedActions=new String[]{RM10Constants.CREATE_SEQUENCE_RESPONSE_ACTION,GREETME_RESPONSE_ACTION,RM10_GENERIC_FAULT_ACTION}; mf.verifyActions(expectedActions,false); oldGreeter.close(); }

InternalCallVerifier EqualityVerifier 
@Test public void testTwowayNonAnonymous() throws Exception { init("org/apache/cxf/systest/ws/rm/rminterceptors.xml",true); assertEquals("ONE",greeter.greetMe("one")); assertEquals("TWO",greeter.greetMe("two")); assertEquals("THREE",greeter.greetMe("three")); verifyTwowayNonAnonymous(); }

EqualityVerifier 
@Test public void testTerminateOnShutdown() throws Exception { init("org/apache/cxf/systest/ws/rm/terminate-on-shutdown.xml",true); RMManager manager=greeterBus.getExtension(RMManager.class); RMMemoryStore store=new RMMemoryStore(); manager.setStore(store); greeter.greetMeOneWay("neutrophil"); greeter.greetMeOneWay("basophil"); greeter.greetMeOneWay("eosinophil"); stopGreeterButNotCloseConduit(); awaitMessages(6,2); MessageFlow mf=new MessageFlow(outRecorder.getOutboundMessages(),inRecorder.getInboundMessages(),Names200408.WSA_NAMESPACE_NAME,RM10Constants.NAMESPACE_URI); mf.verifyMessages(6,true); String[] expectedActions=new String[]{RM10Constants.CREATE_SEQUENCE_ACTION,GREETMEONEWAY_ACTION,GREETMEONEWAY_ACTION,GREETMEONEWAY_ACTION,RM10Constants.CLOSE_SEQUENCE_ACTION,RM10Constants.TERMINATE_SEQUENCE_ACTION}; mf.verifyActions(expectedActions,true); mf.verifyMessageNumbers(new String[]{null,"1","2","3","4",null},true); mf.verifyMessages(2,false); mf.verifyMessageNumbers(new String[2],false); expectedActions=new String[]{RM10Constants.CREATE_SEQUENCE_RESPONSE_ACTION,RM10Constants.SEQUENCE_ACKNOWLEDGMENT_ACTION}; mf.verifyActions(expectedActions,false); mf.verifyAcknowledgements(new boolean[]{false,true},false); assertEquals("sequences not released from DB",0,store.ssmap.size()); assertEquals("messages not released from DB",0,store.ommap.size()); assertEquals("sequence not closed in DB",1,store.ssclosed.size()); }

Class: org.apache.cxf.systest.ws.rm.WSRMPolicyResolveTest

InternalCallVerifier EqualityVerifier 
@Test public void testHello() throws Exception { BasicDocEndpoint port=getApplicationContext().getBean("TestClient",BasicDocEndpoint.class); Object retObj=port.echo("Hello"); assertEquals("Hello",retObj); }

Class: org.apache.cxf.systest.ws.security.SecurityPolicyTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testDispatchClient() throws Exception { SpringBusFactory bf=new SpringBusFactory(); Bus bus=bf.createBus(); SpringBusFactory.setDefaultBus(bus); SpringBusFactory.setThreadDefaultBus(bus); URL wsdl=SecurityPolicyTest.class.getResource("DoubleIt.wsdl"); Service service=Service.create(wsdl,SERVICE_QNAME); QName portQName=new QName(NAMESPACE,"DoubleItPortEncryptThenSign"); Dispatch disp=service.createDispatch(portQName,Source.class,Mode.PAYLOAD); disp.getRequestContext().put(SecurityConstants.CALLBACK_HANDLER,new KeystorePasswordCallback()); disp.getRequestContext().put(SecurityConstants.SIGNATURE_PROPERTIES,"alice.properties"); disp.getRequestContext().put(SecurityConstants.ENCRYPT_PROPERTIES,"bob.properties"); updateAddressPort(disp,PORT); String req="" + "25"; Source source=new StreamSource(new StringReader(req)); source=disp.invoke(source); Node nd=StaxUtils.read(source); if (nd instanceof Document) { nd=((Document)nd).getDocumentElement(); } Map ns=new HashMap(); ns.put("ns2","http://www.example.org/schema/DoubleIt"); XPathUtils xp=new XPathUtils(ns); Object o=xp.getValue("//ns2:DoubleItResponse/doubledNumber",nd,XPathConstants.STRING); assertEquals(StaxUtils.toString(nd),"50",o); bus.shutdown(true); }

APIUtilityVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testSignedOnlyWithUnsignedMessage() throws Exception { SpringBusFactory bf=new SpringBusFactory(); Bus bus=bf.createBus(); SpringBusFactory.setDefaultBus(bus); SpringBusFactory.setThreadDefaultBus(bus); URL wsdl=SecurityPolicyTest.class.getResource("DoubleIt.wsdl"); Service service=Service.create(wsdl,SERVICE_QNAME); DoubleItPortType pt; QName portQName=new QName(NAMESPACE,"DoubleItPortSignedOnly"); pt=service.getPort(portQName,DoubleItPortType.class); updateAddressPort(pt,PORT); ((BindingProvider)pt).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER,new KeystorePasswordCallback()); ((BindingProvider)pt).getRequestContext().put(SecurityConstants.SIGNATURE_PROPERTIES,"alice.properties"); ((BindingProvider)pt).getRequestContext().put(SecurityConstants.ENCRYPT_PROPERTIES,"bob.properties"); assertEquals(10,pt.doubleIt(5)); SecurityTestUtil.enableStreaming(pt); assertEquals(10,pt.doubleIt(5)); ((java.io.Closeable)pt).close(); portQName=new QName(NAMESPACE,"DoubleItPortTimestampOnly"); pt=service.getPort(portQName,DoubleItPortType.class); ((BindingProvider)pt).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,POLICY_SIGNONLY_ADDRESS); try { pt.doubleIt(5); fail("should have had a security/policy exception as the body wasn't signed"); } catch ( Exception ex) { assertTrue(ex.getMessage().contains("policy alternatives")); } try { SecurityTestUtil.enableStreaming(pt); pt.doubleIt(5); fail("should have had a security/policy exception as the body wasn't signed"); } catch ( Exception ex) { } ((java.io.Closeable)pt).close(); bus.shutdown(true); }

APIUtilityVerifier UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testPolicy() throws Exception { SpringBusFactory bf=new SpringBusFactory(); URL busFile=SecurityPolicyTest.class.getResource("https_config_client.xml"); Bus bus=bf.createBus(busFile.toString()); SpringBusFactory.setDefaultBus(bus); SpringBusFactory.setThreadDefaultBus(bus); URL wsdl=SecurityPolicyTest.class.getResource("DoubleIt.wsdl"); Service service=Service.create(wsdl,SERVICE_QNAME); DoubleItPortType pt; QName portQName=new QName(NAMESPACE,"DoubleItPortXPath"); pt=service.getPort(portQName,DoubleItPortType.class); updateAddressPort(pt,PORT); ((BindingProvider)pt).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER,new KeystorePasswordCallback()); ((BindingProvider)pt).getRequestContext().put(SecurityConstants.SIGNATURE_PROPERTIES,"alice.properties"); ((BindingProvider)pt).getRequestContext().put(SecurityConstants.ENCRYPT_PROPERTIES,"bob.properties"); assertEquals(10,pt.doubleIt(5)); ((java.io.Closeable)pt).close(); portQName=new QName(NAMESPACE,"DoubleItPortEncryptThenSign"); pt=service.getPort(portQName,DoubleItPortType.class); updateAddressPort(pt,PORT); ((BindingProvider)pt).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER,new KeystorePasswordCallback()); ((BindingProvider)pt).getRequestContext().put(SecurityConstants.SIGNATURE_PROPERTIES,"alice.properties"); ((BindingProvider)pt).getRequestContext().put(SecurityConstants.ENCRYPT_PROPERTIES,"bob.properties"); pt.doubleIt(5); ((java.io.Closeable)pt).close(); portQName=new QName(NAMESPACE,"DoubleItPortSign"); pt=service.getPort(portQName,DoubleItPortType.class); updateAddressPort(pt,PORT); ((BindingProvider)pt).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER,new KeystorePasswordCallback()); ((BindingProvider)pt).getRequestContext().put(SecurityConstants.SIGNATURE_PROPERTIES,"alice.properties"); ((BindingProvider)pt).getRequestContext().put(SecurityConstants.ENCRYPT_PROPERTIES,"bob.properties"); pt.doubleIt(5); SecurityTestUtil.enableStreaming(pt); pt.doubleIt(5); ((java.io.Closeable)pt).close(); portQName=new QName(NAMESPACE,"DoubleItPortSignThenEncrypt"); pt=service.getPort(portQName,DoubleItPortType.class); updateAddressPort(pt,PORT); ((BindingProvider)pt).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER,new KeystorePasswordCallback()); ((BindingProvider)pt).getRequestContext().put(SecurityConstants.SIGNATURE_PROPERTIES,"alice.properties"); ((BindingProvider)pt).getRequestContext().put(SecurityConstants.ENCRYPT_PROPERTIES,"bob.properties"); pt.doubleIt(5); SecurityTestUtil.enableStreaming(pt); pt.doubleIt(5); ((java.io.Closeable)pt).close(); portQName=new QName(NAMESPACE,"DoubleItPortHttps"); pt=service.getPort(portQName,DoubleItPortType.class); updateAddressPort(pt,SSL_PORT); try { pt.doubleIt(25); } catch ( Exception ex) { String msg=ex.getMessage(); if (!msg.contains("sername")) { throw ex; } } ((BindingProvider)pt).getRequestContext().put(SecurityConstants.USERNAME,"bob"); ((BindingProvider)pt).getRequestContext().put(SecurityConstants.SIGNATURE_USERNAME,"bob"); ((BindingProvider)pt).getRequestContext().put(SecurityConstants.PASSWORD,"pwd"); pt.doubleIt(25); SecurityTestUtil.enableStreaming(pt); pt.doubleIt(25); ((java.io.Closeable)pt).close(); try { portQName=new QName(NAMESPACE,"DoubleItPortHttp"); pt=service.getPort(portQName,DoubleItPortType.class); updateAddressPort(pt,PORT); pt.doubleIt(25); fail("https policy should have triggered"); } catch ( Exception ex) { String msg=ex.getMessage(); if (!msg.contains("HttpsToken")) { throw ex; } } ((java.io.Closeable)pt).close(); bus.shutdown(true); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testCXF3041() throws Exception { SpringBusFactory bf=new SpringBusFactory(); Bus bus=bf.createBus(); SpringBusFactory.setDefaultBus(bus); SpringBusFactory.setThreadDefaultBus(bus); URL wsdl=SecurityPolicyTest.class.getResource("DoubleIt.wsdl"); Service service=Service.create(wsdl,SERVICE_QNAME); DoubleItPortType pt; QName portQName=new QName(NAMESPACE,"DoubleItPortCXF3041"); pt=service.getPort(portQName,DoubleItPortType.class); updateAddressPort(pt,PORT); ((BindingProvider)pt).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER,new KeystorePasswordCallback()); ((BindingProvider)pt).getRequestContext().put(SecurityConstants.SIGNATURE_PROPERTIES,"alice.properties"); ((BindingProvider)pt).getRequestContext().put(SecurityConstants.ENCRYPT_PROPERTIES,"bob.properties"); assertEquals(10,pt.doubleIt(5)); SecurityTestUtil.enableStreaming(pt); assertEquals(10,pt.doubleIt(5)); ((java.io.Closeable)pt).close(); bus.shutdown(true); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testCXF3042() throws Exception { SpringBusFactory bf=new SpringBusFactory(); Bus bus=bf.createBus(); SpringBusFactory.setDefaultBus(bus); SpringBusFactory.setThreadDefaultBus(bus); URL wsdl=SecurityPolicyTest.class.getResource("DoubleIt.wsdl"); Service service=Service.create(wsdl,SERVICE_QNAME); DoubleItPortType pt; QName portQName=new QName(NAMESPACE,"DoubleItPortCXF3042"); pt=service.getPort(portQName,DoubleItPortType.class); updateAddressPort(pt,PORT); ((BindingProvider)pt).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER,new KeystorePasswordCallback()); ((BindingProvider)pt).getRequestContext().put(SecurityConstants.SIGNATURE_PROPERTIES,"alice.properties"); ((BindingProvider)pt).getRequestContext().put(SecurityConstants.ENCRYPT_PROPERTIES,"alice.properties"); assertEquals(10,pt.doubleIt(5)); SecurityTestUtil.enableStreaming(pt); assertEquals(10,pt.doubleIt(5)); ((java.io.Closeable)pt).close(); bus.shutdown(true); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testCXF3452() throws Exception { SpringBusFactory bf=new SpringBusFactory(); Bus bus=bf.createBus(); SpringBusFactory.setDefaultBus(bus); SpringBusFactory.setThreadDefaultBus(bus); URL wsdl=SecurityPolicyTest.class.getResource("DoubleIt.wsdl"); Service service=Service.create(wsdl,SERVICE_QNAME); DoubleItPortTypeHeader pt; QName portQName=new QName(NAMESPACE,"DoubleItPortCXF3452"); pt=service.getPort(portQName,DoubleItPortTypeHeader.class); updateAddressPort(pt,PORT); ((BindingProvider)pt).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER,new KeystorePasswordCallback()); ((BindingProvider)pt).getRequestContext().put(SecurityConstants.SIGNATURE_PROPERTIES,"alice.properties"); ((BindingProvider)pt).getRequestContext().put(SecurityConstants.ENCRYPT_PROPERTIES,"alice.properties"); DoubleIt di=new DoubleIt(); di.setNumberToDouble(5); assertEquals(10,pt.doubleIt(di,1).getDoubledNumber()); ((java.io.Closeable)pt).close(); bus.shutdown(true); }

Class: org.apache.cxf.systest.ws.security.WSSecurityClientTest

APIUtilityVerifier UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testUsernameToken() throws Exception { final javax.xml.ws.Service svc=javax.xml.ws.Service.create(WSDL_LOC,GREETER_SERVICE_QNAME); final Greeter greeter=svc.getPort(USERNAME_TOKEN_PORT_QNAME,Greeter.class); updateAddressPort(greeter,test.getPort()); Client client=ClientProxy.getClient(greeter); Map props=new HashMap(); props.put("action","UsernameToken"); props.put("user","alice"); props.put("passwordType","PasswordText"); WSS4JOutInterceptor wss4jOut=new WSS4JOutInterceptor(props); client.getOutInterceptors().add(wss4jOut); ((BindingProvider)greeter).getRequestContext().put("password","password"); try { greeter.greetMe("CXF"); fail("should fail because of password text instead of digest"); } catch ( Exception ex) { } props.put("passwordType","PasswordDigest"); String s=greeter.greetMe("CXF"); assertEquals("Hello CXF",s); try { ((BindingProvider)greeter).getRequestContext().put("password","foo"); greeter.greetMe("CXF"); fail("should fail"); } catch ( Exception ex) { } try { props.put("passwordType","PasswordText"); ((BindingProvider)greeter).getRequestContext().put("password","password"); greeter.greetMe("CXF"); fail("should fail"); } catch ( Exception ex) { } ((java.io.Closeable)greeter).close(); }

APIUtilityVerifier UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testUsernameTokenStreaming() throws Exception { final javax.xml.ws.Service svc=javax.xml.ws.Service.create(WSDL_LOC,GREETER_SERVICE_QNAME); final Greeter greeter=svc.getPort(USERNAME_TOKEN_PORT_QNAME,Greeter.class); updateAddressPort(greeter,test.getPort()); Client client=ClientProxy.getClient(greeter); Map props=new HashMap(); props.put("action","UsernameToken"); props.put("user","alice"); props.put("passwordType","PasswordText"); WSS4JStaxOutInterceptor wss4jOut=new WSS4JStaxOutInterceptor(props); client.getOutInterceptors().add(wss4jOut); ((BindingProvider)greeter).getRequestContext().put("password","password"); try { greeter.greetMe("CXF"); fail("should fail because of password text instead of digest"); } catch ( Exception ex) { } client.getOutInterceptors().remove(wss4jOut); props.put("passwordType","PasswordDigest"); wss4jOut=new WSS4JStaxOutInterceptor(props); client.getOutInterceptors().add(wss4jOut); String s=greeter.greetMe("CXF"); assertEquals("Hello CXF",s); client.getOutInterceptors().remove(wss4jOut); try { ((BindingProvider)greeter).getRequestContext().put("password","foo"); wss4jOut=new WSS4JStaxOutInterceptor(props); client.getOutInterceptors().add(wss4jOut); greeter.greetMe("CXF"); fail("should fail"); } catch ( Exception ex) { } client.getOutInterceptors().remove(wss4jOut); try { props.put("passwordType","PasswordText"); wss4jOut=new WSS4JStaxOutInterceptor(props); client.getOutInterceptors().add(wss4jOut); ((BindingProvider)greeter).getRequestContext().put("password","password"); greeter.greetMe("CXF"); fail("should fail"); } catch ( Exception ex) { } client.getOutInterceptors().remove(wss4jOut); ((java.io.Closeable)greeter).close(); }

Class: org.apache.cxf.systest.ws.security.handler.WSSecTest

APIUtilityVerifier EqualityVerifier 
@Test public void testClientServer() throws Exception { Bus bus=new SpringBusFactory().createBus("org/apache/cxf/systest/ws/security/handler/client.xml"); BusFactory.setDefaultBus(bus); BusFactory.setThreadDefaultBus(bus); Service service=Service.create(new URL("http://localhost:" + PORT + "/wsse/HelloWorldWS?wsdl"),new QName("http://cxf.apache.org/wsse/handler/helloworld","HelloWorldImplService")); QName portName=new QName("http://cxf.apache.org/wsse/handler/helloworld","HelloWorldPort"); HelloWorld port=service.getPort(portName,HelloWorld.class); updateAddressPort(port,PORT); assertEquals("Hello CXF",port.sayHello("CXF")); bus.shutdown(true); }

Class: org.apache.cxf.systest.ws.wssc.WSSCTest

InternalCallVerifier EqualityVerifier PublicFieldVerifier 
@Test public void testSecureConversation() throws Exception { final wssec.wssc.IPingService port=svc.getPort(new QName("http://WSSec/wssc",test.prefix),wssec.wssc.IPingService.class); if (PORT2.equals(test.port) || STAX_PORT2.equals(test.port)) { ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,"https://localhost:" + test.port + "/"+ test.prefix); } else { ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,"http://localhost:" + test.port + "/"+ test.prefix); } if (test.prefix.charAt(0) == '_') { ((BindingProvider)port).getRequestContext().put(SecurityConstants.STS_TOKEN_DO_CANCEL,Boolean.TRUE); } if (test.streaming) { ((BindingProvider)port).getRequestContext().put(SecurityConstants.ENABLE_STREAMING_SECURITY,"true"); ((BindingProvider)port).getResponseContext().put(SecurityConstants.ENABLE_STREAMING_SECURITY,"true"); } if (test.clearAction) { AbstractPhaseInterceptor clearActionInterceptor=new AbstractPhaseInterceptor(Phase.POST_LOGICAL){ public void handleMessage( Message message) throws Fault { STSClient client=STSUtils.getClient(message,"sct"); client.getOutInterceptors().add(this); message.put(SecurityConstants.STS_CLIENT,client); String s=(String)message.get(SoapBindingConstants.SOAP_ACTION); if (s == null) { s=SoapActionInInterceptor.getSoapAction(message); } if (s != null && s.contains("RST/SCT")) { message.put(SoapBindingConstants.SOAP_ACTION,""); } } } ; clearActionInterceptor.addBefore(SoapPreProtocolOutInterceptor.class.getName()); ((Client)port).getOutInterceptors().add(clearActionInterceptor); } wssec.wssc.PingRequest params=new wssec.wssc.PingRequest(); org.xmlsoap.ping.Ping ping=new org.xmlsoap.ping.Ping(); ping.setOrigin("CXF"); ping.setScenario("Scenario5"); ping.setText("ping"); params.setPing(ping); try { wssec.wssc.PingResponse output=port.ping(params); assertEquals(OUT,output.getPingResponse().getText()); } catch ( Exception ex) { throw new Exception("Error doing " + test.prefix,ex); } ((java.io.Closeable)port).close(); }

Class: org.apache.cxf.systest.ws.wssec10.WSSecurity10Test

InternalCallVerifier EqualityVerifier PublicFieldVerifier 
@Test public void testClientServer(){ BusFactory.setDefaultBus(getStaticBus()); BusFactory.setThreadDefaultBus(getStaticBus()); URL wsdlLocation=null; PingService svc=null; wsdlLocation=getWsdlLocation(test.prefix,test.port); svc=new PingService(wsdlLocation); final IPingService port=svc.getPort(new QName("http://WSSec/wssec10",test.prefix + "_IPingService"),IPingService.class); Client cl=ClientProxy.getClient(port); if (test.streaming) { ((BindingProvider)port).getRequestContext().put(SecurityConstants.ENABLE_STREAMING_SECURITY,"true"); ((BindingProvider)port).getResponseContext().put(SecurityConstants.ENABLE_STREAMING_SECURITY,"true"); } HTTPConduit http=(HTTPConduit)cl.getConduit(); HTTPClientPolicy httpClientPolicy=new HTTPClientPolicy(); httpClientPolicy.setConnectionTimeout(0); httpClientPolicy.setReceiveTimeout(0); http.setClient(httpClientPolicy); String output=port.echo(INPUT); assertEquals(INPUT,output); cl.destroy(); }

Class: org.apache.cxf.systest.ws.wssec10.WSSecurity10UsernameAuthorizationLegacyTest

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testClientServerComplexPolicyUnauthorized(){ String configName="org/apache/cxf/systest/ws/wssec10/client_restricted_unauthorized.xml"; Bus bus=new SpringBusFactory().createBus(configName); IPingService port=getComplexPolicyPort(bus); try { port.echo(INPUT); fail("Frank is unauthorized"); } catch ( Exception ex) { assertEquals("Unauthorized",ex.getMessage()); } bus.shutdown(true); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testClientServerComplexPolicyAuthorized(){ String configName="org/apache/cxf/systest/ws/wssec10/client_restricted.xml"; Bus bus=new SpringBusFactory().createBus(configName); IPingService port=getComplexPolicyPort(bus); final String output=port.echo(INPUT); assertEquals(INPUT,output); bus.shutdown(true); }

Class: org.apache.cxf.systest.ws.wssec10.WSSecurity10UsernameAuthorizationTest

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testClientServerComplexPolicyUnauthorized() throws IOException { String configName="org/apache/cxf/systest/ws/wssec10/client_restricted_unauthorized.xml"; Bus bus=new SpringBusFactory().createBus(configName); IPingService port=getComplexPolicyPort(bus); try { port.echo(INPUT); fail("Frank is unauthorized"); } catch ( Exception ex) { assertEquals("Unauthorized",ex.getMessage()); } ((java.io.Closeable)port).close(); bus.shutdown(true); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testClientServerComplexPolicyAuthorized() throws IOException { String configName="org/apache/cxf/systest/ws/wssec10/client_restricted.xml"; Bus bus=new SpringBusFactory().createBus(configName); IPingService port=getComplexPolicyPort(bus); final String output=port.echo(INPUT); assertEquals(INPUT,output); ((java.io.Closeable)port).close(); bus.shutdown(true); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testClientServerUTOnlyUnauthorized() throws IOException { String configName="org/apache/cxf/systest/ws/wssec10/client_restricted_unauthorized.xml"; Bus bus=new SpringBusFactory().createBus(configName); IPingService port=getUTOnlyPort(bus,true); try { port.echo(INPUT); fail("Frank is unauthorized"); } catch ( Exception ex) { assertEquals("Unauthorized",ex.getMessage()); } ((java.io.Closeable)port).close(); bus.shutdown(true); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testClientServerUTOnlyAuthorized() throws IOException { String configName="org/apache/cxf/systest/ws/wssec10/client_restricted.xml"; Bus bus=new SpringBusFactory().createBus(configName); IPingService port=getUTOnlyPort(bus,false); final String output=port.echo(INPUT); assertEquals(INPUT,output); ((java.io.Closeable)port).close(); bus.shutdown(true); }

Class: org.apache.cxf.systest.wsdl.CrossSchemaImportsTests

EqualityVerifier 
@Test public void testJaxbCrossSchemaImport() throws Exception { testUtilities.setBus((Bus)applicationContext.getBean("cxf")); testUtilities.addDefaultNamespaces(); Server s=testUtilities.getServerForService(new QName("http://apache.org/type_test/doc","TypeTestPortTypeService")); Document wsdl=testUtilities.getWSDLDocument(s); testUtilities.assertValid("//xsd:schema[@targetNamespace='http://apache.org/type_test/doc']/" + "xsd:import[@namespace='http://apache.org/type_test/types1']",wsdl); Assert.assertEquals(1,LifeCycleListenerTester.getInitCount()); Assert.assertEquals(0,LifeCycleListenerTester.getShutdownCount()); ((ConfigurableApplicationContext)applicationContext).close(); Assert.assertEquals(1,LifeCycleListenerTester.getShutdownCount()); }

Class: org.apache.cxf.systest.xmlbeans.ClientServerXmlBeansTest

UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCallFromClient() throws Exception { SpringBusFactory factory=new SpringBusFactory(); Bus bus=factory.createBus("org/apache/cxf/systest/xmlbeans/cxf.xml"); BusFactory.setDefaultBus(bus); URL wsdl=this.getClass().getResource("/wsdl_systest_databinding/xmlbeans/hello_world.wsdl"); assertNotNull("We should have found the WSDL here. ",wsdl); SOAPService ss=new SOAPService(wsdl,SERVICE_NAME); Greeter port=ss.getSoapPort(); updateAddressPort(port,WSDL_PORT); String resp; ClientProxy.getClient(port).getInInterceptors().add(new LoggingInInterceptor()); ClientProxy.getClient(port).getOutInterceptors().add(new LoggingOutInterceptor()); TestEnum.Enum response=port.sayHiEnum(TestEnum.ONE); assertEquals(TestEnum.ONE,response); resp=port.sayHi(); assertEquals("We should get the right response","Bonjour",resp); resp=port.greetMe("Willem"); assertEquals("We should get the right response","Hello Willem",resp); String aresp[]=port.sayHiArray(new String[]{"Dan"}); assertEquals("Hello",aresp[0]); assertEquals("Dan",aresp[1]); try { port.greetMe("fault"); fail("Should have been a fault"); } catch ( GreetMeFault ex) { assertEquals("Some fault detail",ex.getFaultInfo().getGreetMeFaultDetail()); } try { resp=port.greetMe("Invoking greetMe with invalid length string, expecting exception..."); fail("We expect exception here"); } catch ( WebServiceException ex) { assertTrue("Get a wrong exception",ex.getMessage().indexOf("string length (67) is greater than maxLength facet (30)") >= 0); } try { port.pingMe(); fail("We expect exception here"); } catch ( PingMeFault ex) { FaultDetailDocument detailDocument=ex.getFaultInfo(); FaultDetail detail=detailDocument.getFaultDetail(); assertEquals("Wrong faultDetail major",detail.getMajor(),2); assertEquals("Wrong faultDetail minor",detail.getMinor(),1); } }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCallFromDocLitBareClient() throws Exception { SpringBusFactory factory=new SpringBusFactory(); Bus bus=factory.createBus("org/apache/cxf/systest/xmlbeans/cxf.xml"); BusFactory.setDefaultBus(bus); URL wsdl=this.getClass().getResource("/wsdl_systest_databinding/xmlbeans/doc_lit_bare.wsdl"); assertNotNull("We should have found the WSDL here. ",wsdl); org.apache.cxf.xmlbeans.doc_lit_bare.SOAPService ss=new org.apache.cxf.xmlbeans.doc_lit_bare.SOAPService(wsdl,DOC_LIT_BARE_SERVICE); PutLastTradedPricePortType port=ss.getSoapPort(); updateAddressPort(port,WSDL_PORT); ClientProxy.getClient(port).getInInterceptors().add(new LoggingInInterceptor()); ClientProxy.getClient(port).getOutInterceptors().add(new LoggingOutInterceptor()); StringRespTypeDocument resp=port.bareNoParam(); assertEquals("Get a wrong response","Get the request!",resp.getStringRespType()); InDecimalDocument xd=InDecimalDocument.Factory.newInstance(); xd.setInDecimal(new BigDecimal(123)); OutStringDocument response=port.nillableParameter(xd); assertEquals("Get a wrong response","Get the request 123",response.getOutString()); InDocument document=InDocument.Factory.newInstance(); TradePriceData data=document.addNewIn(); data.setTickerPrice(12.33F); data.setTickerSymbol("CXF"); port.putLastTradedPrice(document); InoutDocument inOut=InoutDocument.Factory.newInstance(); data=inOut.addNewInout(); data.setTickerPrice(12.33F); data.setTickerSymbol("CXF"); Holder holder=new Holder(inOut); port.sayHi(holder); assertEquals("Get a wrong response","BAK",holder.value.getInout().getTickerSymbol()); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testXmlBeansHeader() throws Exception { SpringBusFactory factory=new SpringBusFactory(); Bus bus=factory.createBus("org/apache/cxf/systest/xmlbeans/cxf_no_wsdl.xml"); BusFactory.setDefaultBus(bus); URL wsdl=this.getClass().getResource("/wsdl_systest_databinding/xmlbeans/hello_world.wsdl"); assertNotNull("We should have found the WSDL here. ",wsdl); SOAPService ss=new SOAPService(wsdl,SERVICE_NAME); QName soapPort=new QName("http://apache.org/hello_world_soap_http_xmlbeans/xmlbeans","SoapPort"); ss.addPort(soapPort,SOAPBinding.SOAP11HTTP_BINDING,"http://localhost:" + NOWSDL_PORT + "/SoapContext/SoapPort"); Greeter port=ss.getPort(soapPort,Greeter.class); Client client=ClientProxy.getClient(port); List
headers=new ArrayList
(); org.apache.helloWorldSoapHttpXmlbeans.xmlbeans.types.GreetMeDocument doc=org.apache.helloWorldSoapHttpXmlbeans.xmlbeans.types.GreetMeDocument.Factory.newInstance(); doc.addNewGreetMe().setRequestType("doc format header"); Header head=new Header(new QName("","doc"),doc,client.getEndpoint().getService().getDataBinding()); headers.add(head); org.apache.helloWorldSoapHttpXmlbeans.xmlbeans.types.GreetMeDocument.GreetMe gm=org.apache.helloWorldSoapHttpXmlbeans.xmlbeans.types.GreetMeDocument.GreetMe.Factory.newInstance(); gm.setRequestType("non-doc format header"); head=new Header(new QName("http://somenamespace.com","nondocheader"),gm,client.getEndpoint().getService().getDataBinding()); headers.add(head); ((BindingProvider)port).getRequestContext().put(Header.HEADER_LIST,headers); String resp; ClientProxy.getClient(port).getInInterceptors().add(new LoggingInInterceptor()); StringWriter sw=new StringWriter(); PrintWriter pw=new PrintWriter(sw); ClientProxy.getClient(port).getOutInterceptors().add(new LoggingOutInterceptor(pw)); resp=port.sayHi(); assertEquals("We should get the right response",resp,"Bonjour"); assertTrue(sw.toString().contains("doc format header")); assertTrue(sw.toString().contains("non-doc format header")); assertTrue(sw.toString().contains("nondocheader")); }

UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCallFromClientNoWsdlServer() throws Exception { SpringBusFactory factory=new SpringBusFactory(); Bus bus=factory.createBus("org/apache/cxf/systest/xmlbeans/cxf_no_wsdl.xml"); BusFactory.setDefaultBus(bus); URL wsdl=this.getClass().getResource("/wsdl_systest_databinding/xmlbeans/hello_world.wsdl"); assertNotNull("We should have found the WSDL here. ",wsdl); SOAPService ss=new SOAPService(wsdl,SERVICE_NAME); QName soapPort=new QName("http://apache.org/hello_world_soap_http_xmlbeans/xmlbeans","SoapPort"); ss.addPort(soapPort,SOAPBinding.SOAP11HTTP_BINDING,"http://localhost:" + NOWSDL_PORT + "/SoapContext/SoapPort"); Greeter port=ss.getPort(soapPort,Greeter.class); String resp; ClientProxy.getClient(port).getInInterceptors().add(new LoggingInInterceptor()); ClientProxy.getClient(port).getOutInterceptors().add(new LoggingOutInterceptor()); resp=port.sayHi(); assertEquals("We should get the right response",resp,"Bonjour"); resp=port.greetMe("Willem"); assertEquals("We should get the right response",resp,"Hello Willem"); try { resp=port.greetMe("Invoking greetMe with invalid length string, expecting exception..."); fail("We expect exception here"); } catch ( WebServiceException ex) { assertTrue("Get a wrong exception",ex.getMessage().indexOf("string length (67) is greater than maxLength facet (30)") >= 0); } try { port.pingMe(); fail("We expect exception here"); } catch ( PingMeFault ex) { FaultDetailDocument detailDocument=ex.getFaultInfo(); FaultDetail detail=detailDocument.getFaultDetail(); assertEquals("Wrong faultDetail major",detail.getMajor(),2); assertEquals("Wrong faultDetail minor",detail.getMinor(),1); } try { port.greetMe("fault"); fail("Should have been a fault"); } catch ( GreetMeFault ex) { assertEquals("Some fault detail",ex.getFaultInfo().getGreetMeFaultDetail()); } }

Class: org.apache.cxf.testutils.header_test.rpc.TestRPCHeaderTest

APIUtilityVerifier BranchVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testHeader1(){ Method meths[]=cls.getMethods(); for ( Method m : meths) { if ("testHeader1".equals(m.getName())) { Annotation annotations[][]=m.getParameterAnnotations(); assertEquals(2,annotations.length); assertEquals(1,annotations[0].length); assertTrue(annotations[0][0] instanceof WebParam); WebParam parm=(WebParam)annotations[0][0]; assertEquals("http://apache.org/header_test/rpc/types",parm.targetNamespace()); assertEquals("inHeader",parm.partName()); assertEquals("headerMessage",parm.name()); assertTrue(parm.header()); } } }

APIUtilityVerifier BranchVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testInOutHeader(){ Method meths[]=cls.getMethods(); for ( Method m : meths) { if ("testInOutHeader".equals(m.getName())) { Annotation annotations[][]=m.getParameterAnnotations(); assertEquals(2,annotations.length); assertEquals(1,annotations[1].length); assertTrue(annotations[1][0] instanceof WebParam); WebParam parm=(WebParam)annotations[1][0]; assertEquals("http://apache.org/header_test/rpc/types",parm.targetNamespace()); assertEquals("inOutHeader",parm.partName()); assertEquals("headerMessage",parm.name()); assertTrue(parm.header()); } } }

Class: org.apache.cxf.tools.common.ProcessorEnvironmentTest

InternalCallVerifier EqualityVerifier 
@Test public void testGetDefaultValue(){ Map map=new HashMap(); map.put("k1","v1"); ToolContext env=new ToolContext(); env.setParameters(map); String k1=(String)env.get("k1","v2"); assertEquals("v1",k1); String k2=(String)env.get("k2","v2"); assertEquals("v2",k2); }

InternalCallVerifier EqualityVerifier 
@Test public void testPut(){ Map map=new HashMap(); map.put("k1","v1"); ToolContext env=new ToolContext(); env.setParameters(map); env.put("k2","v2"); String value=(String)env.get("k2"); assertEquals("v2",value); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testRemove(){ Map map=new HashMap(); map.put("k1","v1"); ToolContext env=new ToolContext(); env.setParameters(map); env.put("k2","v2"); String value=(String)env.get("k2"); assertEquals("v2",value); env.remove("k1"); assertNull(env.get("k1")); }

InternalCallVerifier EqualityVerifier 
@Test public void testGet(){ Map map=new HashMap(); map.put("k1","v1"); ToolContext env=new ToolContext(); env.setParameters(map); String value=(String)env.get("k1"); assertEquals("v1",value); }

Class: org.apache.cxf.tools.common.ToolContextTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetQName() throws Exception { assertNull(context.getQName(ToolConstants.CFG_SERVICENAME)); context.put(ToolConstants.CFG_SERVICENAME,"SoapService"); QName qname=context.getQName(ToolConstants.CFG_SERVICENAME); assertEquals(new QName(null,"SoapService"),qname); qname=context.getQName(ToolConstants.CFG_SERVICENAME,"http://cxf.org"); assertEquals(new QName("http://cxf.org","SoapService"),qname); context.put(ToolConstants.CFG_SERVICENAME,"http://apache.org=SoapService"); qname=context.getQName(ToolConstants.CFG_SERVICENAME); assertEquals(new QName("http://apache.org","SoapService"),qname); }

Class: org.apache.cxf.tools.common.WSDLVersionTest

EqualityVerifier 
@Test public void testWSDLVersion(){ assertEquals(WSDLConstants.WSDLVersion.WSDL11,WSDLConstants.getVersion("1.1")); assertEquals(WSDLConstants.WSDLVersion.WSDL20,WSDLConstants.getVersion("2.0")); assertEquals(WSDLConstants.WSDLVersion.UNKNOWN,WSDLConstants.getVersion("3.0")); }

Class: org.apache.cxf.tools.common.dom.ExtendedDocumentBuilderTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testParse() throws Exception { ExtendedDocumentBuilder builder=new ExtendedDocumentBuilder(); String tsSource="/org/apache/cxf/tools/common/toolspec/parser/resources/testtool1.xml"; Document doc=builder.parse(getClass().getResourceAsStream(tsSource)); assertEquals(doc.getXmlVersion(),"1.0"); }

Class: org.apache.cxf.tools.common.model.JAnnotationTest

InternalCallVerifier EqualityVerifier 
@Test public void testEnum(){ JAnnotation annotation=new JAnnotation(SOAPBinding.class); annotation.addElement(new JAnnotationElement("parameterStyle",SOAPBinding.ParameterStyle.BARE)); assertEquals("@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)",annotation.toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testPrimitive(){ JAnnotation annotation=new JAnnotation(WebParam.class); annotation.addElement(new JAnnotationElement("header",true,true)); annotation.addElement(new JAnnotationElement("mode",Mode.INOUT)); assertEquals("@WebParam(header = true, mode = WebParam.Mode.INOUT)",annotation.toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testList() throws Exception { JAnnotation annotation=new JAnnotation(XmlSeeAlso.class); annotation.addElement(new JAnnotationElement(null,Arrays.asList(new Class[]{XmlSeeAlso.class}))); assertEquals("@XmlSeeAlso({XmlSeeAlso.class})",annotation.toString()); assertEquals("javax.xml.bind.annotation.XmlSeeAlso",annotation.getImports().iterator().next()); }

InternalCallVerifier EqualityVerifier 
@Test public void testStringForm(){ JAnnotation annotation=new JAnnotation(WebService.class); annotation.addElement(new JAnnotationElement("name","AddNumbersPortType")); annotation.addElement(new JAnnotationElement("targetNamespace","http://example.com/")); assertEquals("@WebService(name = \"AddNumbersPortType\", targetNamespace = \"http://example.com/\")",annotation.toString()); }

EqualityVerifier 
@Test public void testSimpleForm(){ JAnnotation annotation=new JAnnotation(WebService.class); assertEquals("@WebService",annotation.toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testAddSame(){ JAnnotation annotation=new JAnnotation(WebParam.class); annotation.addElement(new JAnnotationElement("header",true,true)); annotation.addElement(new JAnnotationElement("header",false,true)); annotation.addElement(new JAnnotationElement("mode",Mode.INOUT)); annotation.addElement(new JAnnotationElement("mode",Mode.OUT)); assertEquals("@WebParam(header = false, mode = WebParam.Mode.OUT)",annotation.toString()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testCombination(){ JAnnotation annotation=new JAnnotation(Action.class); annotation.addElement(new JAnnotationElement("input","3in")); annotation.addElement(new JAnnotationElement("output","3out")); JAnnotation faultAction=new JAnnotation(FaultAction.class); faultAction.addElement(new JAnnotationElement("className",A.class)); faultAction.addElement(new JAnnotationElement("value","3fault")); annotation.addElement(new JAnnotationElement("fault",Arrays.asList(new JAnnotation[]{faultAction}))); String expected="@Action(input = \"3in\", output = \"3out\", " + "fault = {@FaultAction(className = A.class, value = \"3fault\")})"; assertEquals(expected,annotation.toString()); assertTrue(annotation.getImports().contains("javax.xml.ws.FaultAction")); assertTrue(annotation.getImports().contains("javax.xml.ws.Action")); assertTrue(annotation.getImports().contains("org.apache.cxf.tools.common.model.A")); }

Class: org.apache.cxf.tools.common.model.JavaClassTest

InternalCallVerifier EqualityVerifier 
@Test public void testGetterSetterStringArray(){ JavaField field=new JavaField("array","String[]","http://doc.withannotation.fortest.tools.cxf.apache.org/"); JavaClass clz=new JavaClass(); clz.setFullClassName("org.apache.cxf.tools.fortest.withannotation.doc.jaxws.SayHi"); JavaMethod getter=clz.appendGetter(field); assertEquals("getArray",getter.getName()); assertEquals("String[]",getter.getReturn().getClassName()); assertEquals("array",getter.getReturn().getName()); assertEquals("return this.array;",getter.getJavaCodeBlock().getExpressions().get(0).toString()); JavaMethod setter=clz.appendSetter(field); assertEquals("setArray",setter.getName()); assertEquals("void",setter.getReturn().getClassName()); assertEquals("array",getter.getReturn().getName()); assertEquals("String[]",setter.getParameters().get(0).getClassName()); assertEquals("this.array = newArray;",setter.getJavaCodeBlock().getExpressions().get(0).toString()); field=new JavaField("return","String[]","http://doc.withannotation.fortest.tools.cxf.apache.org/"); clz=new JavaClass(); clz.setFullClassName("org.apache.cxf.tools.fortest.withannotation.doc.jaxws.SayHiResponse"); getter=clz.appendGetter(field); assertEquals("getReturn",getter.getName()); assertEquals("String[]",getter.getReturn().getClassName()); assertEquals("_return",getter.getReturn().getName()); setter=clz.appendSetter(field); assertEquals("setReturn",setter.getName()); assertEquals("void",setter.getReturn().getClassName()); assertEquals("_return",getter.getReturn().getName()); assertEquals("String[]",setter.getParameters().get(0).getClassName()); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetterSetter() throws Exception { JavaField field=new JavaField("arg0","org.apache.cxf.tools.fortest.withannotation.doc.TestDataBean","http://doc.withannotation.fortest.tools.cxf.apache.org/"); JavaClass clz=new JavaClass(); clz.setFullClassName("org.apache.cxf.tools.fortest.withannotation.doc.jaxws.EchoDataBean"); JavaMethod getter=clz.appendGetter(field); assertEquals("getArg0",getter.getName()); assertEquals("org.apache.cxf.tools.fortest.withannotation.doc.TestDataBean",getter.getReturn().getClassName()); assertEquals("arg0",getter.getReturn().getName()); JavaMethod setter=clz.appendSetter(field); assertEquals("setArg0",setter.getName()); assertEquals("void",setter.getReturn().getClassName()); assertEquals("arg0",getter.getReturn().getName()); assertEquals("org.apache.cxf.tools.fortest.withannotation.doc.TestDataBean",setter.getParameters().get(0).getClassName()); }

Class: org.apache.cxf.tools.common.model.JavaInterfaceTest

InternalCallVerifier EqualityVerifier 
@Test public void testSetFullClassName() throws Exception { String fullName="org.apache.cxf.tools.common.model.JavaInterface"; JavaInterface intf=new JavaInterface(); intf.setFullClassName(fullName); assertEquals("org.apache.cxf.tools.common.model",intf.getPackageName()); assertEquals("JavaInterface",intf.getName()); }

Class: org.apache.cxf.tools.common.model.JavaParameterTest

InternalCallVerifier EqualityVerifier 
@Test public void testGetHolderDefaultTypeValue() throws Exception { JavaParameter holderParameter=new JavaParameter("i","java.lang.String",null); holderParameter.setHolder(true); holderParameter.setHolderName("javax.xml.ws.Holder"); assertEquals("\"\"",holderParameter.getDefaultTypeValue()); holderParameter=new JavaParameter("org.apache.cxf.tools.common.model.JavaParameter","org.apache.cxf.tools.common.model.JavaParameter",null); holderParameter.setHolder(true); holderParameter.setHolderName("javax.xml.ws.Holder"); String defaultTypeValue=holderParameter.getDefaultTypeValue(); assertEquals("new org.apache.cxf.tools.common.model.JavaParameter()",defaultTypeValue); }

Class: org.apache.cxf.tools.common.model.JavaTypeTest

EqualityVerifier 
@Test public void testGetArrayDefaultTypeValue() throws Exception { assertEquals("new int[0]",new JavaType("i","int[]",null).getDefaultTypeValue()); assertEquals("new String[0]",new JavaType("i","String[]",null).getDefaultTypeValue()); }

EqualityVerifier 
@Test public void testGetClassDefaultTypeValue() throws Exception { assertEquals("new org.apache.cxf.tools.common.model.JavaType()",new JavaType("i","org.apache.cxf.tools.common.model.JavaType",null).getDefaultTypeValue()); }

EqualityVerifier 
@Test public void testGetPredefinedDefaultTypeValue() throws Exception { assertEquals("0",new JavaType("i",int.class.getName(),null).getDefaultTypeValue()); assertEquals("false",new JavaType("i",boolean.class.getName(),null).getDefaultTypeValue()); assertEquals("new javax.xml.namespace.QName(\"\", \"\")",new JavaType("i",javax.xml.namespace.QName.class.getName(),null).getDefaultTypeValue()); }

InternalCallVerifier EqualityVerifier 
@Test public void testSetClass(){ JavaType type=new JavaType(); type.setClassName("foo.bar.A"); assertEquals("foo.bar",type.getPackageName()); assertEquals("A",type.getSimpleName()); }

Class: org.apache.cxf.tools.common.toolspec.AbstractToolContainerTest

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testInit(){ try { dummyTool.init(); } catch ( ToolException e) { assertEquals("Tool specification has to be set before initializing",e.getMessage()); return; } assertTrue(true); }

Class: org.apache.cxf.tools.common.toolspec.ToolSpecTest

APIUtilityVerifier EqualityVerifier 
@Test public void testGetStreamRefName1() throws Exception { String tsSource="parser/resources/testtool1.xml"; toolSpec=new ToolSpec(getClass().getResourceAsStream(tsSource),false); assertEquals("test getStreamRefName failed",toolSpec.getStreamRefName("streamref"),"namespace"); }

APIUtilityVerifier EqualityVerifier 
@Test public void testGetStreamRefName2() throws Exception { String tsSource="parser/resources/testtool2.xml"; toolSpec=new ToolSpec(getClass().getResourceAsStream(tsSource),false); assertEquals("test getStreamRefName2 failed",toolSpec.getStreamRefName("streamref"),"wsdlurl"); }

Class: org.apache.cxf.tools.common.toolspec.parser.CommandLineParserTest

UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testInvalidPackageName(){ try { String[] args=new String[]{"-p","/test","arg1"}; parser.parseArguments(args); fail("testInvalidPackageName failed"); } catch ( BadUsageException ex) { Object[] errors=ex.getErrors().toArray(); assertEquals("testInvalidPackageName failed",1,errors.length); CommandLineError error=(CommandLineError)errors[0]; assertTrue("Expected InvalidArgumentValue error",error instanceof ErrorVisitor.UserError); ErrorVisitor.UserError userError=(ErrorVisitor.UserError)error; assertEquals("Invalid argument value message incorrect","-p has invalid character!",userError.toString()); } }

APIUtilityVerifier IterativeVerifier BranchVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testFormattedDetailedUsage() throws Exception { String usage=parser.getFormattedDetailedUsage(); assertNotNull(usage); StringTokenizer st1=new StringTokenizer(usage,System.getProperty("line.separator")); assertEquals(14,st1.countTokens()); while (st1.hasMoreTokens()) { String s=st1.nextToken(); if (s.indexOf("java package") != -1) { s=s.trim(); assertTrue(s.charAt(s.length() - 1) != 'o'); } else if (s.indexOf("impl - the") != -1) { assertTrue(s.charAt(s.length() - 1) == 'o'); } } }

IterativeVerifier InternalCallVerifier EqualityVerifier 
@Test public void testDetailedUsage() throws Exception { String specialItem="[ -p <[wsdl namespace =]Package Name> ]*"; if (!isQuolifiedVersion()) { specialItem="-p <[wsdl namespace =]Package Name>*"; } String[] expected=new String[]{"[ -n ]","Namespace","[ -impl ]","impl - the impl that will be used by this tool to do " + "whatever it is this tool does.","[ -e ]","enum","-r","required",specialItem,"The java package name to use for the generated code." + "Also, optionally specify the wsdl namespace mapping to " + "a particular java packagename.","[ -? ]","help","[ -v ]","version","","WSDL/SCHEMA URL"}; int index=0; String lineSeparator=System.getProperty("line.separator"); StringTokenizer st1=new StringTokenizer(parser.getDetailedUsage(),lineSeparator); while (st1.hasMoreTokens()) { assertEquals("Failed at line " + index,expected[index++],st1.nextToken().toString().trim()); } }

UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testUnexpectedOption(){ try { String[] args=new String[]{"-n","test","-r","-unknown"}; parser.parseArguments(args); fail("testUnexpectedOption failed"); } catch ( BadUsageException ex) { Object[] errors=ex.getErrors().toArray(); assertEquals("testInvalidOption failed",1,errors.length); CommandLineError error=(CommandLineError)errors[0]; assertTrue("Expected UnexpectedOption error",error instanceof ErrorVisitor.UnexpectedOption); ErrorVisitor.UnexpectedOption option=(ErrorVisitor.UnexpectedOption)error; assertEquals("UnexpectedOption incorrect","-unknown",option.getOptionSwitch()); } }

InternalCallVerifier EqualityVerifier 
@Test public void testValidArgumentEnumValue() throws Exception { String[] args=new String[]{"-r","-e","true","arg1"}; CommandDocument result=parser.parseArguments(args); assertEquals("testValidArguments Failed","true",result.getParameter("enum")); }

UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testInvalidArgumentEnumValue() throws Exception { try { String[] args=new String[]{"-e","wrongvalue"}; parser.parseArguments(args); fail("testInvalidArgumentEnumValue failed"); } catch ( BadUsageException ex) { Object[] errors=ex.getErrors().toArray(); assertEquals("testInvalidArgumentEnumValu failed",1,errors.length); CommandLineError error=(CommandLineError)errors[0]; assertTrue("Expected InvalidArgumentEnumValu error",error instanceof ErrorVisitor.UserError); ErrorVisitor.UserError userError=(ErrorVisitor.UserError)error; assertEquals("Invalid enum argument value message incorrect","-e wrongvalue not in the enumeration value list!",userError.toString()); } }

BranchVerifier InternalCallVerifier EqualityVerifier 
@Test public void testUsage() throws Exception { String usage="[ -n ] [ -impl ] [ -e ] -r " + "[ -p <[wsdl namespace =]Package Name> ]* [ -? ] [ -v ] "; String pUsage=parser.getUsage(); if (isQuolifiedVersion()) { assertEquals("This test failed in the xerces version above 2.7.1 or the version with JDK ",usage,pUsage); } else { usage="[ -n ] [ -impl ] [ -e ] -r " + "-p <[wsdl namespace =]Package Name>* [ -? ] [ -v ] "; assertEquals("This test failed in the xerces version below 2.7.1",usage.trim(),pUsage.trim()); } }

UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testMissingArgument(){ try { String[] args=new String[]{"-n","test","-r"}; parser.parseArguments(args); fail("testMissingArgument failed"); } catch ( BadUsageException ex) { Object[] errors=ex.getErrors().toArray(); assertEquals("testInvalidOption failed",1,errors.length); CommandLineError error=(CommandLineError)errors[0]; assertTrue("Expected MissingArgument error",error instanceof ErrorVisitor.MissingArgument); ErrorVisitor.MissingArgument arg=(ErrorVisitor.MissingArgument)error; assertEquals("MissingArgument incorrect","wsdlurl",arg.getArgument()); } }

UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testInvalidOption(){ try { String[] args=new String[]{"-n","-r","arg1"}; parser.parseArguments(args); fail("testInvalidOption failed"); } catch ( BadUsageException ex) { Object[] errors=ex.getErrors().toArray(); assertEquals("testInvalidOption failed",1,errors.length); CommandLineError error=(CommandLineError)errors[0]; assertTrue("Expected InvalidOption error",error instanceof ErrorVisitor.InvalidOption); ErrorVisitor.InvalidOption option=(ErrorVisitor.InvalidOption)error; assertEquals("Invalid option incorrect","-n",option.getOptionSwitch()); assertEquals("Invalid option message incorrect","Invalid option: -n is missing its associated argument",option.toString()); } }

InternalCallVerifier EqualityVerifier 
@Test public void testValidArguments() throws Exception { String[] args=new String[]{"-r","-n","test","arg1"}; CommandDocument result=parser.parseArguments(args); assertEquals("testValidArguments Failed","test",result.getParameter("namespace")); }

UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testDuplicateArgument(){ try { String[] args=new String[]{"-n","test","-r","arg1","arg2"}; parser.parseArguments(args); fail("testUnexpectedArgument failed"); } catch ( BadUsageException ex) { Object[] errors=ex.getErrors().toArray(); assertEquals("testInvalidOption failed",1,errors.length); CommandLineError error=(CommandLineError)errors[0]; assertTrue("Expected UnexpectedArgument error",error instanceof ErrorVisitor.UnexpectedArgument); } }

UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testMissingOption(){ try { String[] args=new String[]{"-n","test","arg1"}; parser.parseArguments(args); fail("testMissingOption failed"); } catch ( BadUsageException ex) { Object[] errors=ex.getErrors().toArray(); assertEquals("testInvalidOption failed",1,errors.length); CommandLineError error=(CommandLineError)errors[0]; assertTrue("Expected MissingOption error",error instanceof ErrorVisitor.MissingOption); ErrorVisitor.MissingOption option=(ErrorVisitor.MissingOption)error; assertEquals("Missing option incorrect","r",option.getOptionSwitch()); } }

UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testInvalidArgumentValue() throws Exception { try { String[] args=new String[]{"-n","test@","arg1"}; parser.parseArguments(args); fail("testInvalidArgumentValue failed"); } catch ( BadUsageException ex) { Object[] errors=ex.getErrors().toArray(); assertEquals("testInvalidArgumentValue failed",1,errors.length); CommandLineError error=(CommandLineError)errors[0]; assertTrue("Expected InvalidArgumentValue error",error instanceof ErrorVisitor.UserError); ErrorVisitor.UserError userError=(ErrorVisitor.UserError)error; assertEquals("Invalid argument value message incorrect","-n has invalid character!",userError.toString()); } }

InternalCallVerifier EqualityVerifier 
@Test public void testvalidPackageName() throws Exception { String[] args=new String[]{"-p","http://www.iona.com/hello_world_soap_http=com.iona","-r","arg1"}; CommandDocument result=parser.parseArguments(args); assertEquals("testValidPackageName Failed","http://www.iona.com/hello_world_soap_http=com.iona",result.getParameter("packagename")); }

InternalCallVerifier EqualityVerifier 
@Test public void testValidMixedArguments() throws Exception { String[] args=new String[]{"-v","-r","-n","test","arg1"}; CommandDocument result=parser.parseArguments(args); assertEquals("testValidMissedArguments Failed","test",result.getParameter("namespace")); }

Class: org.apache.cxf.tools.corba.processors.IDLToWSDLGenerationTest

BranchVerifier InternalCallVerifier EqualityVerifier 
@Test public void testEncodingGeneration() throws Exception { try { String sourceIdlFilename="/idl/Enum.idl"; URL idl=getClass().getResource(sourceIdlFilename); ProcessorEnvironment env=new ProcessorEnvironment(); Map cfg=new HashMap(); cfg.put(ToolCorbaConstants.CFG_IDLFILE,new File(idl.toURI()).getAbsolutePath()); cfg.put(ToolCorbaConstants.CFG_WSDL_ENCODING,"UTF-16"); env.setParameters(cfg); IDLToWSDLProcessor processor=new IDLToWSDLProcessor(); processor.setEnvironment(env); Writer out=processor.getOutputWriter("Enum.wsdl","."); if (out instanceof OutputStreamWriter) { OutputStreamWriter writer=(OutputStreamWriter)out; assertEquals("Encoding should be UTF-16",writer.getEncoding(),"UTF-16"); } out.close(); } finally { new File("Enum.wsdl").deleteOnExit(); } }

Class: org.apache.cxf.tools.corba.processors.WSDLToCorbaBindingTest

APIUtilityVerifier IterativeVerifier BranchVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testArrayMapping() throws Exception { try { String fileName=getClass().getResource("/wsdl/array.wsdl").toString(); generator.setWsdlFile(fileName); generator.addInterfaceName("X"); Definition model=generator.generateCORBABinding(); QName bName=new QName("http://schemas.apache.org/idl/anon.idl","XCORBABinding","tns"); Binding binding=model.getBinding(bName); assertNotNull(binding); assertEquals("XCORBABinding",binding.getQName().getLocalPart()); assertEquals("X",binding.getPortType().getQName().getLocalPart()); assertEquals(1,binding.getExtensibilityElements().size()); assertEquals(1,binding.getBindingOperations().size()); for ( ExtensibilityElement extElement : getExtensibilityElements(binding)) { if (extElement.getElementType().getLocalPart().equals("binding")) { BindingType bindingType=(BindingType)extElement; assertEquals(bindingType.getRepositoryID(),"IDL:X:1.0"); } } Iterator j=binding.getBindingOperations().iterator(); while (j.hasNext()) { BindingOperation bindingOperation=(BindingOperation)j.next(); assertEquals(1,bindingOperation.getExtensibilityElements().size()); assertEquals(bindingOperation.getBindingInput().getName(),"op_a"); assertEquals(bindingOperation.getBindingOutput().getName(),"op_aResponse"); for ( ExtensibilityElement extElement : getExtensibilityElements(bindingOperation)) { if (extElement.getElementType().getLocalPart().equals("operation")) { OperationType corbaOpType=(OperationType)extElement; assertEquals(corbaOpType.getName(),"op_a"); assertEquals(1,corbaOpType.getParam().size()); assertNotNull(corbaOpType.getReturn()); ParamType paramtype=corbaOpType.getParam().get(0); assertEquals(paramtype.getName(),"part1"); QName idltype=new QName("http://schemas.apache.org/idl/anon.idl/corba/typemap/","ArrayType","ns1"); assertEquals(paramtype.getIdltype(),idltype); assertEquals(paramtype.getMode().toString(),"IN"); } } } WSDLToIDLAction idlgen=new WSDLToIDLAction(); idlgen.setBindingName("XCORBABinding"); idlgen.setOutputFile("array.idl"); idlgen.generateIDL(model); File f=new File("array.idl"); assertTrue("array.idl should be generated",f.exists()); } finally { new File("array.idl").deleteOnExit(); } }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testUnionType() throws Exception { try { String fileName=getClass().getResource("/wsdl/uniontype.wsdl").toString(); generator.setWsdlFile(fileName); generator.addInterfaceName("Test.MultiPart"); Definition model=generator.generateCORBABinding(); Document document=writer.getDocument(model); Element typemap=getElementNode(document,"corba:typeMapping"); assertNotNull(typemap); assertEquals(1,typemap.getElementsByTagName("corba:union").getLength()); assertEquals(1,typemap.getElementsByTagName("corba:enum").getLength()); WSDLToIDLAction idlgen=new WSDLToIDLAction(); idlgen.setBindingName("Test.MultiPartCORBABinding"); idlgen.setOutputFile("uniontype.idl"); idlgen.generateIDL(model); File f=new File("uniontype.idl"); assertTrue("uniontype.idl should be generated",f.exists()); } finally { new File("uniontype.idl").deleteOnExit(); } }

APIUtilityVerifier IterativeVerifier BranchVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testMixedArraysMapping() throws Exception { try { String fileName=getClass().getResource("/wsdl/arrays-mixed.wsdl").toString(); generator.setWsdlFile(fileName); generator.addInterfaceName("X"); Definition model=generator.generateCORBABinding(); QName bName=new QName("http://schemas.apache.org/idl/anon.idl","XCORBABinding","tns"); Binding binding=model.getBinding(bName); assertNotNull(binding); assertEquals("XCORBABinding",binding.getQName().getLocalPart()); assertEquals("X",binding.getPortType().getQName().getLocalPart()); assertEquals(1,binding.getExtensibilityElements().size()); assertEquals(1,binding.getBindingOperations().size()); for ( ExtensibilityElement extElement : getExtensibilityElements(binding)) { if (extElement.getElementType().getLocalPart().equals("binding")) { BindingType bindingType=(BindingType)extElement; assertEquals(bindingType.getRepositoryID(),"IDL:X:1.0"); } } Iterator tm=model.getExtensibilityElements().iterator(); assertTrue(tm.hasNext()); TypeMappingType tmt=(TypeMappingType)tm.next(); CorbaTypeMap typeMap=CorbaUtils.createCorbaTypeMap(Arrays.asList(tmt)); assertNull("All nested anonymous types should have \"nested\" names",typeMap.getType("item")); assertMixedArraysMappingEasyTypes(typeMap); assertMixedArraysMappingDifficultSequences(typeMap); assertMixedArraysMappingDifficultArrays(typeMap); Iterator j=binding.getBindingOperations().iterator(); while (j.hasNext()) { BindingOperation bindingOperation=(BindingOperation)j.next(); assertEquals(1,bindingOperation.getExtensibilityElements().size()); assertEquals(bindingOperation.getBindingInput().getName(),"op_a"); assertEquals(bindingOperation.getBindingOutput().getName(),"op_aResponse"); for ( ExtensibilityElement extElement : getExtensibilityElements(bindingOperation)) { if (extElement.getElementType().getLocalPart().equals("operation")) { OperationType corbaOpType=(OperationType)extElement; assertEquals(corbaOpType.getName(),"op_a"); assertEquals(1,corbaOpType.getParam().size()); assertNotNull(corbaOpType.getReturn()); ParamType paramtype=corbaOpType.getParam().get(0); assertEquals(paramtype.getName(),"part1"); QName idltype=new QName("http://schemas.apache.org/idl/anon.idl/corba/typemap/","MixedArrayType","ns1"); assertEquals(paramtype.getIdltype(),idltype); assertEquals(paramtype.getMode().toString(),"IN"); } else if (extElement.getElementType().getLocalPart().equals("typeMapping")) { System.out.println("x"); } } } WSDLToIDLAction idlgen=new WSDLToIDLAction(); idlgen.setBindingName("XCORBABinding"); idlgen.setOutputFile("array.idl"); idlgen.generateIDL(model); File f=new File("array.idl"); assertTrue("array.idl should be generated",f.exists()); } finally { new File("array.idl").deleteOnExit(); } }

APIUtilityVerifier IterativeVerifier InternalCallVerifier EqualityVerifier 
@Test public void testFixedBindingGeneration() throws Exception { String fileName=getClass().getResource("/wsdl/fixed.wsdl").toString(); generator.setWsdlFile(fileName); generator.addInterfaceName("Y"); Definition model=generator.generateCORBABinding(); Document document=writer.getDocument(model); Element typemap=getElementNode(document,"corba:typeMapping"); assertEquals(1,typemap.getElementsByTagName("corba:sequence").getLength()); assertEquals(5,typemap.getElementsByTagName("corba:fixed").getLength()); Element bindingElement=getElementNode(document,"binding"); assertEquals(5,bindingElement.getElementsByTagName("corba:operation").getLength()); QName bName=new QName("http://schemas.apache.org/idl/fixed.idl","YCORBABinding","tns"); Binding binding=model.getBinding(bName); TypeMappingType mapType=(TypeMappingType)model.getExtensibilityElements().get(0); Map tmap=new HashMap(); for ( CorbaType type : mapType.getStructOrExceptionOrUnion()) { tmap.put(type.getName(),type); } Iterator j=binding.getBindingOperations().iterator(); while (j.hasNext()) { BindingOperation bindingOperation=(BindingOperation)j.next(); assertEquals("YCORBABinding",binding.getQName().getLocalPart()); assertEquals(1,bindingOperation.getExtensibilityElements().size()); checkFixedTypeOne(bindingOperation,tmap); bindingOperation=(BindingOperation)j.next(); checkSequenceType(bindingOperation,tmap); bindingOperation=(BindingOperation)j.next(); checkFixedTypeTwo(bindingOperation,tmap); bindingOperation=(BindingOperation)j.next(); checkFixedTypeThree(bindingOperation,tmap); bindingOperation=(BindingOperation)j.next(); checkFixedTypeFour(bindingOperation,tmap); } }

APIUtilityVerifier BranchVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testMultipartCORBABindingGeneration() throws Exception { String fileName=getClass().getResource("/wsdl/multipart.wsdl").toString(); generator.setWsdlFile(fileName); generator.addInterfaceName("Test.MultiPart"); Definition model=generator.generateCORBABinding(); QName bName=new QName("http://schemas.apache.org/tests","Test.MultiPartCORBABinding","tns"); Binding binding=model.getBinding(bName); assertNotNull(binding); assertEquals("Test.MultiPartCORBABinding",binding.getQName().getLocalPart()); assertEquals("Test.MultiPart",binding.getPortType().getQName().getLocalPart()); assertEquals(1,binding.getExtensibilityElements().size()); assertEquals(32,binding.getBindingOperations().size()); List extElements=getExtensibilityElements(binding); ExtensibilityElement extElement=extElements.get(0); if (extElement.getElementType().getLocalPart().equals("binding")) { BindingType bindingType=(BindingType)extElement; assertEquals(bindingType.getRepositoryID(),"IDL:Test/MultiPart:1.0"); } getStringAttributeTest(binding); getTestIdTest(binding); setTestIdTest(binding); testVoidTest(binding); testPrimitiveTypeTest(binding,"test_short",CorbaConstants.NT_CORBA_SHORT); testPrimitiveTypeTest(binding,"test_long",CorbaConstants.NT_CORBA_LONG); testPrimitiveTypeTest(binding,"test_longlong",CorbaConstants.NT_CORBA_LONGLONG); testPrimitiveTypeTest(binding,"test_ushort",CorbaConstants.NT_CORBA_USHORT); testPrimitiveTypeTest(binding,"test_ulong",CorbaConstants.NT_CORBA_ULONG); testPrimitiveTypeTest(binding,"test_ulonglong",CorbaConstants.NT_CORBA_ULONGLONG); testPrimitiveTypeTest(binding,"test_float",CorbaConstants.NT_CORBA_FLOAT); testPrimitiveTypeTest(binding,"test_double",CorbaConstants.NT_CORBA_DOUBLE); testPrimitiveTypeTest(binding,"test_octet",CorbaConstants.NT_CORBA_OCTET); testPrimitiveTypeTest(binding,"test_boolean",CorbaConstants.NT_CORBA_BOOLEAN); testPrimitiveTypeTest(binding,"test_char",CorbaConstants.NT_CORBA_CHAR); testPrimitiveTypeTest(binding,"test_integer",CorbaConstants.NT_CORBA_LONGLONG); testPrimitiveTypeTest(binding,"test_nonNegativeInteger",CorbaConstants.NT_CORBA_ULONGLONG); testPrimitiveTypeTest(binding,"test_positiveInteger",CorbaConstants.NT_CORBA_ULONGLONG); testPrimitiveTypeTest(binding,"test_negativeInteger",CorbaConstants.NT_CORBA_LONGLONG); testPrimitiveTypeTest(binding,"test_normalizedString",CorbaConstants.NT_CORBA_STRING); testPrimitiveTypeTest(binding,"test_token",CorbaConstants.NT_CORBA_STRING); testPrimitiveTypeTest(binding,"test_language",CorbaConstants.NT_CORBA_STRING); testPrimitiveTypeTest(binding,"test_Name",CorbaConstants.NT_CORBA_STRING); testPrimitiveTypeTest(binding,"test_NCName",CorbaConstants.NT_CORBA_STRING); testPrimitiveTypeTest(binding,"test_ID",CorbaConstants.NT_CORBA_STRING); testPrimitiveTypeTest(binding,"test_anyURI",CorbaConstants.NT_CORBA_STRING); testPrimitiveTypeTest(binding,"test_nick_name",CorbaConstants.NT_CORBA_STRING); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testMultipartTypeMapGeneration() throws Exception { String fileName=getClass().getResource("/wsdl/multipart.wsdl").toString(); generator.setWsdlFile(fileName); generator.addInterfaceName("Test.MultiPart"); Definition model=generator.generateCORBABinding(); Document document=writer.getDocument(model); Element typemap=getElementNode(document,"corba:typeMapping"); assertNotNull(typemap); assertEquals(1,typemap.getElementsByTagName("corba:enum").getLength()); }

APIUtilityVerifier IterativeVerifier BranchVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCORBABindingGeneration() throws Exception { String fileName=getClass().getResource("/wsdl/simpleList.wsdl").toString(); generator.setWsdlFile(fileName); generator.addInterfaceName("BasePortType"); Definition model=generator.generateCORBABinding(); QName bName=new QName("http://schemas.apache.org/tests","BaseCORBABinding","tns"); Binding binding=model.getBinding(bName); assertNotNull(binding); assertEquals("BaseCORBABinding",binding.getQName().getLocalPart()); assertEquals("BasePortType",binding.getPortType().getQName().getLocalPart()); assertEquals(1,binding.getExtensibilityElements().size()); assertEquals(1,binding.getBindingOperations().size()); for ( ExtensibilityElement extElement : getExtensibilityElements(binding)) { if (extElement.getElementType().getLocalPart().equals("binding")) { BindingType bindingType=(BindingType)extElement; assertEquals(bindingType.getRepositoryID(),"IDL:BasePortType:1.0"); } } Iterator j=binding.getBindingOperations().iterator(); while (j.hasNext()) { BindingOperation bindingOperation=(BindingOperation)j.next(); assertEquals(1,bindingOperation.getExtensibilityElements().size()); assertEquals(bindingOperation.getBindingInput().getName(),"echoString"); assertEquals(bindingOperation.getBindingOutput().getName(),"echoStringResponse"); for ( ExtensibilityElement extElement : getExtensibilityElements(bindingOperation)) { if (extElement.getElementType().getLocalPart().equals("operation")) { OperationType corbaOpType=(OperationType)extElement; assertEquals(corbaOpType.getName(),"echoString"); assertEquals(3,corbaOpType.getParam().size()); assertEquals(corbaOpType.getReturn().getName(),"return"); assertEquals(corbaOpType.getReturn().getIdltype(),CorbaConstants.NT_CORBA_STRING); assertEquals(corbaOpType.getParam().get(0).getName(),"x"); assertEquals(corbaOpType.getParam().get(0).getMode().value(),"in"); QName qname=new QName("http://schemas.apache.org/tests/corba/typemap/","StringEnum1","ns1"); assertEquals(corbaOpType.getParam().get(0).getIdltype(),qname); } } } }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testAllType() throws Exception { try { String fileName=getClass().getResource("/wsdl/alltype.wsdl").toString(); generator.setWsdlFile(fileName); generator.addInterfaceName("BasePortType"); Definition model=generator.generateCORBABinding(); Document document=writer.getDocument(model); Element typemap=getElementNode(document,"corba:typeMapping"); assertEquals(1,typemap.getElementsByTagName("corba:struct").getLength()); WSDLToIDLAction idlgen=new WSDLToIDLAction(); idlgen.setBindingName("BaseCORBABinding"); idlgen.setOutputFile("alltype.idl"); idlgen.generateIDL(model); File f=new File("alltype.idl"); assertTrue("alltype.idl should be generated",f.exists()); } finally { new File("alltype.idl").deleteOnExit(); } }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSequenceType() throws Exception { try { String fileName=getClass().getResource("/wsdl/sequencetype.wsdl").toString(); generator.setWsdlFile(fileName); generator.addInterfaceName("IACC.Server"); Definition model=generator.generateCORBABinding(); Document document=writer.getDocument(model); Element typemap=getElementNode(document,"corba:typeMapping"); assertNotNull(typemap); assertEquals(2,typemap.getElementsByTagName("corba:sequence").getLength()); assertEquals(5,typemap.getElementsByTagName("corba:exception").getLength()); assertEquals(70,typemap.getElementsByTagName("corba:struct").getLength()); WSDLToIDLAction idlgen=new WSDLToIDLAction(); idlgen.setBindingName("IACC.ServerCORBABinding"); idlgen.setOutputFile("sequencetype.idl"); idlgen.generateIDL(model); File f=new File("sequencetype.idl"); assertTrue("sequencetype.idl should be generated",f.exists()); } finally { new File("sequencetype.idl").deleteOnExit(); } }

APIUtilityVerifier IterativeVerifier BranchVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testExceptionCORBABindingGeneration() throws Exception { String fileName=getClass().getResource("/wsdl/exceptions.wsdl").toString(); generator.setWsdlFile(fileName); generator.addInterfaceName("TestException.ExceptionTest"); Definition model=generator.generateCORBABinding(); QName bName=new QName("http://schemas.apache.org/idl/exceptions.idl","TestException.ExceptionTestCORBABinding","tns"); Binding binding=model.getBinding(bName); assertNotNull(binding); assertEquals("TestException.ExceptionTestCORBABinding",binding.getQName().getLocalPart()); assertEquals("TestException.ExceptionTest",binding.getPortType().getQName().getLocalPart()); assertEquals(1,binding.getExtensibilityElements().size()); assertEquals(1,binding.getBindingOperations().size()); for ( ExtensibilityElement extElement : getExtensibilityElements(binding)) { if (extElement.getElementType().getLocalPart().equals("binding")) { BindingType bindingType=(BindingType)extElement; assertEquals(bindingType.getRepositoryID(),"IDL:TestException/ExceptionTest:1.0"); } } Iterator j=binding.getBindingOperations().iterator(); while (j.hasNext()) { BindingOperation bindingOperation=(BindingOperation)j.next(); assertEquals(1,bindingOperation.getExtensibilityElements().size()); assertEquals(bindingOperation.getBindingInput().getName(),"review_data"); assertEquals(bindingOperation.getBindingOutput().getName(),"review_dataResponse"); Iterator f=bindingOperation.getBindingFaults().values().iterator(); boolean hasBadRecord=false; boolean hasMyException=false; while (f.hasNext()) { BindingFault bindingFault=(BindingFault)f.next(); if ("TestException.BadRecord".equals(bindingFault.getName())) { hasBadRecord=true; } else if ("MyException".equals(bindingFault.getName())) { hasMyException=true; } else { fail("Unexpected BindingFault: " + bindingFault.getName()); } } assertTrue("Did not get expected TestException.BadRecord",hasBadRecord); assertTrue("Did not get expected MyException",hasMyException); for ( ExtensibilityElement extElement : getExtensibilityElements(bindingOperation)) { if (extElement.getElementType().getLocalPart().equals("operation")) { OperationType corbaOpType=(OperationType)extElement; assertEquals(corbaOpType.getName(),"review_data"); assertEquals(1,corbaOpType.getParam().size()); assertEquals(2,corbaOpType.getRaises().size()); hasBadRecord=false; hasMyException=false; for (int k=0; k < corbaOpType.getRaises().size(); k++) { String localPart=corbaOpType.getRaises().get(k).getException().getLocalPart(); if ("TestException.BadRecord".equals(localPart)) { hasBadRecord=true; } else if ("MyExceptionType".equals(localPart)) { hasMyException=true; } else { fail("Unexpected Raises: " + localPart); } } assertTrue("Did not find expected TestException.BadRecord",hasBadRecord); assertTrue("Did not find expected MyException",hasMyException); } } } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCORBATypeMapGeneration() throws Exception { String fileName=getClass().getResource("/wsdl/simpleList.wsdl").toString(); generator.setWsdlFile(fileName); generator.addInterfaceName("BasePortType"); Definition model=generator.generateCORBABinding(); Document document=writer.getDocument(model); Element typemap=getElementNode(document,"corba:typeMapping"); assertNotNull(typemap); assertEquals(2,typemap.getElementsByTagName("corba:sequence").getLength()); assertEquals(1,typemap.getElementsByTagName("corba:enum").getLength()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testComplexContentStructType() throws Exception { try { String fileName=getClass().getResource("/wsdl/content.wsdl").toString(); generator.setWsdlFile(fileName); generator.addInterfaceName("ContentPortType"); Definition model=generator.generateCORBABinding(); Document document=writer.getDocument(model); Element typemap=getElementNode(document,"corba:typeMapping"); assertEquals(1,typemap.getElementsByTagName("corba:union").getLength()); assertEquals(6,typemap.getElementsByTagName("corba:struct").getLength()); WSDLToIDLAction idlgen=new WSDLToIDLAction(); idlgen.setBindingName("ContentCORBABinding"); idlgen.setOutputFile("content.idl"); idlgen.generateIDL(model); File f=new File("content.idl"); assertTrue("content.idl should be generated",f.exists()); } finally { new File("content.idl").deleteOnExit(); } }

Class: org.apache.cxf.tools.corba.processors.WSDLToCorbaBindingTypeTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testNestedDerivedTypes() throws Exception { try { String fileName=getClass().getResource("/wsdl/nested-derivedtypes.wsdl").toString(); generator.setWsdlFile(fileName); generator.addInterfaceName("DerivedTypesPortType"); Definition model=generator.generateCORBABinding(); Document document=writer.getDocument(model); Element typemap=getElementNode(document,"corba:typeMapping"); assertNotNull(typemap); assertEquals(6,typemap.getElementsByTagName("corba:union").getLength()); assertEquals(58,typemap.getElementsByTagName("corba:struct").getLength()); assertEquals(3,typemap.getElementsByTagName("corba:sequence").getLength()); WSDLToIDLAction idlgen=new WSDLToIDLAction(); idlgen.setBindingName("DerivedTypesCORBABinding"); idlgen.setOutputFile("nested-derivedtypes.idl"); idlgen.generateIDL(model); File f=new File("nested-derivedtypes.idl"); assertTrue("nested-derivedtypes.idl should be generated",f.exists()); } finally { new File("nested-derivedtypes.idl").deleteOnExit(); } }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testWsAddressingAccountType() throws Exception { try { String fileName=getClass().getResource("/wsdl/wsaddressing_bank.wsdl").toString(); generator.setWsdlFile(fileName); generator.addInterfaceName("Bank"); Definition model=generator.generateCORBABinding(); Document document=writer.getDocument(model); Element typemap=getElementNode(document,"corba:typeMapping"); assertNotNull(typemap); assertEquals(1,DOMUtils.findAllElementsByTagNameNS(typemap,"http://cxf.apache.org/bindings/corba","sequence").size()); assertEquals(2,DOMUtils.findAllElementsByTagNameNS(typemap,"http://cxf.apache.org/bindings/corba","object").size()); WSDLToIDLAction idlgen=new WSDLToIDLAction(); idlgen.setBindingName("BankCORBABinding"); idlgen.setOutputFile("wsaddressing_bank.idl"); idlgen.generateIDL(model); File f=new File("wsaddressing_bank.idl"); assertTrue("wsaddressing_bank.idl should be generated",f.exists()); } finally { new File("wsaddressing_bank.idl").deleteOnExit(); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testComplexRestriction() throws Exception { try { URI fileName=getClass().getResource("/wsdl/complexRestriction.wsdl").toURI(); generator.setWsdlFile(new File(fileName).getAbsolutePath()); generator.addInterfaceName("TypeTestPortType"); Definition model=generator.generateCORBABinding(); Document document=writer.getDocument(model); Element typemap=getElementNode(document,"corba:typeMapping"); assertNotNull(typemap); assertEquals(1,typemap.getElementsByTagName("corba:struct").getLength()); } finally { new File("complexRestriction-corba.wsdl").deleteOnExit(); } }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testNestedComplexTypes() throws Exception { try { String fileName=getClass().getResource("/wsdl/nested_complex.wsdl").toString(); generator.setWsdlFile(fileName); generator.addInterfaceName("X"); Definition model=generator.generateCORBABinding(); Document document=writer.getDocument(model); Element typemap=getElementNode(document,"corba:typeMapping"); assertNotNull(typemap); assertEquals(6,typemap.getElementsByTagName("corba:union").getLength()); assertEquals(14,typemap.getElementsByTagName("corba:struct").getLength()); assertEquals(1,typemap.getElementsByTagName("corba:enum").getLength()); assertEquals(1,typemap.getElementsByTagName("corba:array").getLength()); WSDLToIDLAction idlgen=new WSDLToIDLAction(); idlgen.setBindingName("XCORBABinding"); idlgen.setOutputFile("nested_complex.idl"); idlgen.generateIDL(model); File f=new File("nested_complex.idl"); assertTrue("nested_complex.idl should be generated",f.exists()); } finally { new File("nested_complex.idl").deleteOnExit(); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAnonymousReturnParam() throws Exception { try { String fileName=getClass().getResource("/wsdl/factory_pattern.wsdl").toString(); generator.setWsdlFile(fileName); generator.addInterfaceName("Number"); Definition model=generator.generateCORBABinding(); Document document=writer.getDocument(model); Element typemap=getElementNode(document,"corba:typeMapping"); assertNotNull(typemap); assertEquals(3,typemap.getElementsByTagName("corba:struct").getLength()); } finally { new File("factory_pattern-corba.wsdl").deleteOnExit(); } }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAnonType() throws Exception { try { String fileName=getClass().getResource("/wsdl/atype.wsdl").toString(); generator.setWsdlFile(fileName); generator.addInterfaceName("X"); Definition model=generator.generateCORBABinding(); Document document=writer.getDocument(model); Element typemap=getElementNode(document,"corba:typeMapping"); assertNotNull(typemap); assertEquals(3,typemap.getElementsByTagName("corba:anonsequence").getLength()); assertEquals(2,typemap.getElementsByTagName("corba:anonarray").getLength()); assertEquals(1,typemap.getElementsByTagName("corba:array").getLength()); assertEquals(2,typemap.getElementsByTagName("corba:struct").getLength()); TypeMappingType mapType=(TypeMappingType)model.getExtensibilityElements().get(0); Map tmap=new HashMap(); for ( CorbaType type : mapType.getStructOrExceptionOrUnion()) { tmap.put(type.getName(),type); } WSDLToIDLAction idlgen=new WSDLToIDLAction(); idlgen.setBindingName("XCORBABinding"); idlgen.setOutputFile("atype.idl"); idlgen.generateIDL(model); Array arr=(Array)tmap.get("X.A"); assertNotNull(arr); assertEquals("ElementType is incorrect for Array Type","X._5_A",arr.getElemtype().getLocalPart()); Anonarray arr2=(Anonarray)tmap.get("X._5_A"); assertNotNull(arr2); assertEquals("ElementType is incorrect for Anon Array Type","X._4_A",arr2.getElemtype().getLocalPart()); Anonarray arr3=(Anonarray)tmap.get("X._4_A"); assertNotNull(arr3); assertEquals("ElementType is incorrect for Anon Array Type","X._1_A",arr3.getElemtype().getLocalPart()); Anonsequence seq=(Anonsequence)tmap.get("X._1_A"); assertNotNull(seq); assertEquals("ElementType is incorrect for Anon Sequence Type","X._2_A",seq.getElemtype().getLocalPart()); Anonsequence seq2=(Anonsequence)tmap.get("X._2_A"); assertNotNull(seq2); assertEquals("ElementType is incorrect for Anon Sequence Type","X._3_A",seq2.getElemtype().getLocalPart()); Anonsequence seq3=(Anonsequence)tmap.get("X._3_A"); assertNotNull(seq3); assertEquals("ElementType is incorrect for Anon Sequence Type","long",seq3.getElemtype().getLocalPart()); File f=new File("atype.idl"); assertTrue("atype.idl should be generated",f.exists()); } finally { new File("atype.idl").deleteOnExit(); } }

InternalCallVerifier EqualityVerifier 
@Test public void testMultipleBindings() throws Exception { String fileName=getClass().getResource("/wsdl/multiplePortTypes.wsdl").toString(); generator.setWsdlFile(fileName); generator.setAllBindings(true); Definition model=generator.generateCORBABinding(); assertEquals("All bindings should be generated.",2,model.getAllBindings().size()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testImportSchemaInTypes() throws Exception { try { URI fileName=getClass().getResource("/wsdl/importType.wsdl").toURI(); generator.setWsdlFile(new File(fileName).getAbsolutePath()); generator.addInterfaceName("TypeTestPortType"); Definition model=generator.generateCORBABinding(); Document document=writer.getDocument(model); Element typemap=getElementNode(document,"corba:typeMapping"); assertNotNull(typemap); assertEquals(1,typemap.getElementsByTagName("corba:enum").getLength()); assertEquals(1,typemap.getElementsByTagName("corba:sequence").getLength()); } finally { new File("importType-corba.wsdl").deleteOnExit(); } }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testNestedType() throws Exception { try { String fileName=getClass().getResource("/wsdl/nested.wsdl").toString(); generator.setWsdlFile(fileName); generator.addInterfaceName("TypeInheritancePortType"); Definition model=generator.generateCORBABinding(); Document document=writer.getDocument(model); Element typemap=getElementNode(document,"corba:typeMapping"); assertNotNull(typemap); assertEquals(4,typemap.getElementsByTagName("corba:union").getLength()); assertEquals(23,typemap.getElementsByTagName("corba:struct").getLength()); assertEquals(1,typemap.getElementsByTagName("corba:anonstring").getLength()); WSDLToIDLAction idlgen=new WSDLToIDLAction(); idlgen.setBindingName("TypeInheritanceCORBABinding"); idlgen.setOutputFile("nested.idl"); idlgen.generateIDL(model); File f=new File("nested.idl"); assertTrue("nested.idl should be generated",f.exists()); } finally { new File("nested.idl").deleteOnExit(); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testListType() throws Exception { try { URI fileName=getClass().getResource("/wsdl/listType.wsdl").toURI(); generator.setWsdlFile(new File(fileName).getAbsolutePath()); generator.addInterfaceName("TypeTestPortType"); Definition model=generator.generateCORBABinding(); Document document=writer.getDocument(model); Element typemap=getElementNode(document,"corba:typeMapping"); assertNotNull(typemap); assertEquals(1,typemap.getElementsByTagName("corba:enum").getLength()); assertEquals(1,typemap.getElementsByTagName("corba:sequence").getLength()); } finally { new File("listType-corba.wsdl").deleteOnExit(); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCorbaExceptionComplextype() throws Exception { try { String fileName=getClass().getResource("/wsdl/databaseService.wsdl").toString(); generator.setWsdlFile(fileName); generator.addInterfaceName("Database"); Definition model=generator.generateCORBABinding(); Document document=writer.getDocument(model); Element typemap=getElementNode(document,"corba:typeMapping"); assertNotNull(typemap); assertEquals(2,typemap.getElementsByTagName("corba:struct").getLength()); assertEquals(1,typemap.getElementsByTagName("corba:exception").getLength()); assertEquals(1,typemap.getElementsByTagName("corba:anonsequence").getLength()); } finally { new File("databaseService-corba.wsdl").deleteOnExit(); } }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testWsAddressingBankType() throws Exception { try { String fileName=getClass().getResource("/wsdl/wsaddressing_account.wsdl").toString(); generator.setWsdlFile(fileName); generator.addInterfaceName("Account"); Definition model=generator.generateCORBABinding(); Document document=writer.getDocument(model); Element typemap=getElementNode(document,"corba:typeMapping"); assertNotNull(typemap); assertEquals(1,typemap.getElementsByTagName("corba:object").getLength()); WSDLToIDLAction idlgen=new WSDLToIDLAction(); idlgen.setBindingName("AccountCORBABinding"); idlgen.setOutputFile("wsaddressing_account.idl"); idlgen.generateIDL(model); File f=new File("wsaddressing_account.idl"); assertTrue("wsaddressing_account.idl should be generated",f.exists()); } finally { new File("wsaddressing_account.idl").deleteOnExit(); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testComplextypeDerivedSimpletype() throws Exception { try { String fileName=getClass().getResource("/wsdl/complex_types.wsdl").toString(); generator.setWsdlFile(fileName); generator.addInterfaceName("TypeTestPortType"); Definition model=generator.generateCORBABinding(); Document document=writer.getDocument(model); Element typemap=getElementNode(document,"corba:typeMapping"); assertNotNull(typemap); assertEquals(8,typemap.getElementsByTagName("corba:struct").getLength()); assertEquals(1,typemap.getElementsByTagName("corba:fixed").getLength()); assertEquals(1,typemap.getElementsByTagName("corba:array").getLength()); assertEquals(5,typemap.getElementsByTagName("corba:union").getLength()); assertEquals(3,typemap.getElementsByTagName("corba:sequence").getLength()); } finally { new File("complex_types-corba.wsdl").deleteOnExit(); } }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testRestrictedStruct() throws Exception { try { URI fileName=getClass().getResource("/wsdl/restrictedStruct.wsdl").toURI(); generator.setWsdlFile(new File(fileName).getAbsolutePath()); generator.addInterfaceName("TypeTestPortType"); Definition model=generator.generateCORBABinding(); Document document=writer.getDocument(model); Element typemap=getElementNode(document,"corba:typeMapping"); assertNotNull(typemap); assertEquals(7,typemap.getElementsByTagName("corba:struct").getLength()); assertEquals(3,typemap.getElementsByTagName("corba:union").getLength()); } finally { new File("restrictedStruct-corba.wsdl").deleteOnExit(); } }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAnyType() throws Exception { try { String fileName=getClass().getResource("/wsdl/any.wsdl").toString(); generator.setWsdlFile(fileName); generator.addInterfaceName("anyInterface"); Definition model=generator.generateCORBABinding(); TypeMappingType mapType=(TypeMappingType)model.getExtensibilityElements().get(0); assertEquals(5,mapType.getStructOrExceptionOrUnion().size()); int strcnt=0; int unioncnt=0; for ( CorbaType corbaType : mapType.getStructOrExceptionOrUnion()) { if (corbaType instanceof Struct) { strcnt++; } if (corbaType instanceof Union) { unioncnt++; } } assertNotNull(mapType); assertEquals(3,strcnt); assertEquals(2,unioncnt); WSDLToIDLAction idlgen=new WSDLToIDLAction(); idlgen.setBindingName("anyInterfaceCORBABinding"); idlgen.setOutputFile("any.idl"); idlgen.generateIDL(model); File f=new File("any.idl"); assertTrue("any.idl should be generated",f.exists()); } finally { new File("any.idl").deleteOnExit(); } }

InternalCallVerifier EqualityVerifier 
@Test public void testSetCorbaAddressFile() throws Exception { try { URI fileName=getClass().getResource("/wsdl/datetime.wsdl").toURI(); generator.setWsdlFile(new File(fileName).getAbsolutePath()); generator.addInterfaceName("BasePortType"); Definition model=generator.generateCORBABinding(); QName name=new QName("http://schemas.apache.org/idl/datetime.idl","BaseCORBAService","tns"); Service service=model.getService(name); Port port=service.getPort("BaseCORBAPort"); AddressType addressType=(AddressType)port.getExtensibilityElements().get(0); String address=addressType.getLocation(); assertEquals("file:./Base.ref",address); URL idl=getClass().getResource("/wsdl/addressfile.txt"); String filename=new File(idl.toURI()).getAbsolutePath(); generator.setAddressFile(filename); model=generator.generateCORBABinding(); service=model.getService(name); port=service.getPort("BaseCORBAPort"); addressType=(AddressType)port.getExtensibilityElements().get(0); address=addressType.getLocation(); assertEquals("corbaloc::localhost:60000/hw",address); } finally { new File("datetime-corba.wsdl").deleteOnExit(); } }

InternalCallVerifier EqualityVerifier 
@Test public void testSetCorbaAddress() throws Exception { try { String fileName=getClass().getResource("/wsdl/datetime.wsdl").toString(); generator.setWsdlFile(fileName); generator.addInterfaceName("BasePortType"); Definition model=generator.generateCORBABinding(); QName name=new QName("http://schemas.apache.org/idl/datetime.idl","BaseCORBAService","tns"); Service service=model.getService(name); Port port=service.getPort("BaseCORBAPort"); AddressType addressType=(AddressType)port.getExtensibilityElements().get(0); String address=addressType.getLocation(); assertEquals("file:./Base.ref",address); generator.setAddress("corbaloc::localhost:40000/hw"); model=generator.generateCORBABinding(); service=model.getService(name); port=service.getPort("BaseCORBAPort"); addressType=(AddressType)port.getExtensibilityElements().get(0); address=addressType.getLocation(); assertEquals("corbaloc::localhost:40000/hw",address); } finally { new File("datetime-corba.wsdl").deleteOnExit(); } }

APIUtilityVerifier IterativeVerifier BranchVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testTypeInheritance() throws Exception { try { String fileName=getClass().getResource("/wsdl/TypeInheritance.wsdl").toString(); generator.setWsdlFile(fileName); generator.addInterfaceName("TypeInheritancePortType"); Definition model=generator.generateCORBABinding(); Document document=writer.getDocument(model); Element typemap=getElementNode(document,"corba:typeMapping"); assertNotNull(typemap); assertEquals(3,typemap.getElementsByTagName("corba:union").getLength()); assertEquals(1,typemap.getElementsByTagName("corba:anonstring").getLength()); assertEquals(17,typemap.getElementsByTagName("corba:struct").getLength()); TypeMappingType mapType=(TypeMappingType)model.getExtensibilityElements().get(0); WSDLToIDLAction idlgen=new WSDLToIDLAction(); idlgen.setBindingName("TypeInheritanceCORBABinding"); idlgen.setOutputFile("typeInherit.idl"); idlgen.generateIDL(model); List types=mapType.getStructOrExceptionOrUnion(); for (int i=0; i < types.size(); i++) { CorbaType type=types.get(i); if ("Type5SequenceStruct".equals(type.getName())) { assertTrue("Name is incorrect for Type5SequenceStruct Type",type instanceof Struct); assertEquals("Type is incorrect for AnonSequence Type","Type5",type.getType().getLocalPart()); } else if ("attrib2Type".equals(type.getName())) { assertTrue("Name is incorrect for attrib2Type Type",type instanceof Anonstring); assertEquals("Type is incorrect for AnonString Type","string",type.getType().getLocalPart()); } else if ("attrib2Type_nil".equals(type.getName())) { assertTrue("Name is incorrect for Struct Type",type instanceof Union); assertEquals("Type is incorrect for AnonSequence Type","attrib2",type.getType().getLocalPart()); } } File f=new File("typeInherit.idl"); assertTrue("typeInherit.idl should be generated",f.exists()); } finally { new File("typeInherit.idl").deleteOnExit(); } }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testNestedInterfaceTypes() throws Exception { try { String fileName=getClass().getResource("/wsdl/nested_interfaces.wsdl").toString(); generator.setWsdlFile(fileName); generator.addInterfaceName("C.C1"); Definition model=generator.generateCORBABinding(); Document document=writer.getDocument(model); Element typemap=getElementNode(document,"corba:typeMapping"); assertNotNull(typemap); assertEquals(1,typemap.getElementsByTagName("corba:anonstring").getLength()); assertEquals(9,typemap.getElementsByTagName("corba:struct").getLength()); WSDLToIDLAction idlgen=new WSDLToIDLAction(); idlgen.setBindingName("C.C1CORBABinding"); idlgen.setOutputFile("nested_interfaces.idl"); idlgen.generateIDL(model); File f=new File("nested_interfaces.idl"); assertTrue("nested_interfaces.idl should be generated",f.exists()); } finally { new File("nested_interfaces.idl").deleteOnExit(); } }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDateTimeTypes() throws Exception { try { String fileName=getClass().getResource("/wsdl/datetime.wsdl").toString(); generator.setWsdlFile(fileName); generator.addInterfaceName("BasePortType"); Definition model=generator.generateCORBABinding(); Document document=writer.getDocument(model); Element typemap=getElementNode(document,"corba:typeMapping"); assertNotNull(typemap); assertEquals(2,typemap.getElementsByTagName("corba:union").getLength()); assertEquals(2,typemap.getElementsByTagName("corba:struct").getLength()); WSDLToIDLAction idlgen=new WSDLToIDLAction(); idlgen.setBindingName("BaseCORBABinding"); idlgen.setOutputFile("datetime.idl"); idlgen.generateIDL(model); File f=new File("datetime.idl"); assertTrue("datetime.idl should be generated",f.exists()); } finally { new File("datetime.idl").deleteOnExit(); } }

APIUtilityVerifier IterativeVerifier BranchVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAnonFixedType() throws Exception { try { String fileName=getClass().getResource("/wsdl/anonfixed.wsdl").toString(); generator.setWsdlFile(fileName); generator.addInterfaceName("X"); Definition model=generator.generateCORBABinding(); Document document=writer.getDocument(model); Element typemap=getElementNode(document,"corba:typeMapping"); assertNotNull(typemap); assertEquals(1,typemap.getElementsByTagName("corba:anonfixed").getLength()); assertEquals(1,typemap.getElementsByTagName("corba:anonstring").getLength()); assertEquals(3,typemap.getElementsByTagName("corba:struct").getLength()); TypeMappingType mapType=(TypeMappingType)model.getExtensibilityElements().get(0); WSDLToIDLAction idlgen=new WSDLToIDLAction(); idlgen.setBindingName("XCORBABinding"); idlgen.setOutputFile("atype.idl"); idlgen.generateIDL(model); List types=mapType.getStructOrExceptionOrUnion(); for (int i=0; i < types.size(); i++) { CorbaType type=types.get(i); if (type instanceof Anonstring) { Anonstring str=(Anonstring)type; assertEquals("Name is incorrect for Array Type","X._1_S",str.getName()); assertEquals("Type is incorrect for AnonString Type","string",str.getType().getLocalPart()); } else if (type instanceof Anonfixed) { Anonfixed fx=(Anonfixed)type; assertEquals("Name is incorrect for Anon Array Type","X._2_S",fx.getName()); assertEquals("Type is incorrect for AnonFixed Type","decimal",fx.getType().getLocalPart()); } else if (type instanceof Struct) { Struct struct=(Struct)type; String[] testResult; if ("X.op_a".equals(struct.getName())) { testResult=new String[]{"X.op_a","X.op_a","p1","X.S","p2","X.S"}; } else if ("X.op_aResult".equals(struct.getName())) { testResult=new String[]{"X.op_aResult","X.op_aResult","return","X.S","p2","X.S"}; } else { testResult=new String[]{"X.S","X.S","str","X._1_S","fx","X._2_S"}; } assertEquals("Name is incorrect for Anon Array Type",testResult[0],struct.getName()); assertEquals("Type is incorrect for Struct Type",testResult[1],struct.getType().getLocalPart()); assertEquals("Name for first Struct Member Type is incorrect",testResult[2],struct.getMember().get(0).getName()); assertEquals("Idltype for first Struct Member Type is incorrect",testResult[3],struct.getMember().get(0).getIdltype().getLocalPart()); assertEquals("Name for second Struct Member Type is incorrect",testResult[4],struct.getMember().get(1).getName()); assertEquals("Idltype for second Struct Member Type is incorrect",testResult[5],struct.getMember().get(1).getIdltype().getLocalPart()); } else { } } File f=new File("atype.idl"); assertTrue("atype.idl should be generated",f.exists()); } finally { new File("atype.idl").deleteOnExit(); } }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testWsAddressingTypes() throws Exception { try { String fileName=getClass().getResource("/wsdl/wsaddressing_server.wsdl").toString(); generator.setWsdlFile(fileName); generator.addInterfaceName("TestServer"); Definition model=generator.generateCORBABinding(); Document document=writer.getDocument(model); Element typemap=getElementNode(document,"corba:typeMapping"); assertNotNull(typemap); assertEquals(1,typemap.getElementsByTagName("corba:object").getLength()); WSDLToIDLAction idlgen=new WSDLToIDLAction(); idlgen.setBindingName("TestServerCORBABinding"); idlgen.setOutputFile("wsaddressing_server.idl"); idlgen.generateIDL(model); File f=new File("wsaddressing_server.idl"); assertTrue("wsaddressing_server.idl should be generated",f.exists()); } finally { new File("wsaddressing_server.idl").deleteOnExit(); } }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testNillableType() throws Exception { try { String fileName=getClass().getResource("/wsdl/nillable.wsdl").toString(); generator.setWsdlFile(fileName); generator.addInterfaceName("NillablePortType"); Definition model=generator.generateCORBABinding(); Document document=writer.getDocument(model); Element typemap=getElementNode(document,"corba:typeMapping"); assertNotNull(typemap); assertEquals(2,typemap.getElementsByTagName("corba:union").getLength()); assertEquals(1,typemap.getElementsByTagName("corba:struct").getLength()); TypeMappingType mapType=(TypeMappingType)model.getExtensibilityElements().get(0); WSDLToIDLAction idlgen=new WSDLToIDLAction(); idlgen.setBindingName("NillableCORBABinding"); idlgen.setOutputFile("nillable.idl"); idlgen.generateIDL(model); Union un=(Union)mapType.getStructOrExceptionOrUnion().get(2); assertEquals("Name is incorrect for Union Type","long_nil",un.getName()); assertEquals("Type is incorrect for Union Type","PEl",un.getType().getLocalPart()); Unionbranch unbranch=un.getUnionbranch().get(0); assertEquals("Name is incorrect for UnionBranch Type","value",unbranch.getName()); assertEquals("Type is incorrect for UnionBranch Type","long",unbranch.getIdltype().getLocalPart()); File f=new File("nillable.idl"); assertTrue("nillable.idl should be generated",f.exists()); } finally { new File("nillable.idl").deleteOnExit(); } }

Class: org.apache.cxf.tools.java2ws.AegisTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testAegisReconfigureDatabinding() throws Exception { final String sei=org.apache.cxf.tools.fortest.aegis2ws.TestAegisSEI.class.getName(); String[] args=new String[]{"-wsdl","-o",output.getPath() + "/aegis.wsdl","-beans",new File(inputData,"revisedAegisDefaultBeans.xml").getAbsolutePath(),"-verbose","-s",output.getPath(),"-frontend","jaxws","-databinding","aegis","-client","-server",sei}; File wsdlFile=null; wsdlFile=outputFile("aegis.wsdl"); JavaToWS.main(args); assertTrue("wsdl is not generated " + getStdErr(),wsdlFile.exists()); WSDLReader reader=WSDLFactory.newInstance().newWSDLReader(); reader.setFeature("javax.wsdl.verbose",false); Definition def=reader.readWSDL(wsdlFile.toURI().toURL().toString()); Document wsdl=WSDLFactory.newInstance().newWSDLWriter().getDocument(def); assertValid("//xsd:element[@type='ns0:Something']",wsdl); XPathUtils xpu=new XPathUtils(getNSMap()); String s=(String)xpu.getValue("//xsd:complexType[@name='takeSomething']/" + "xsd:sequence/xsd:element[@name='arg0']/@minOccurs",wsdl,XPathConstants.STRING); assertEquals("50",s); assertFalse(xpu.isExist("//xsd:complexType[@name='Something']/xsd:sequence/" + "xsd:element[@name='singular']/@minOccurs",wsdl,XPathConstants.NODE)); }

Class: org.apache.cxf.tools.java2ws.JavaToWSTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testXmlJavaTypeAdapter() throws Exception { String[] args=new String[]{"-o",output.getPath() + "/xmladapter.wsdl","-verbose","-wsdl","org.apache.xmladapter.GreeterImpl"}; JavaToWS.main(args); File file=new File(output.getPath() + "/xmladapter.wsdl"); Document doc=StaxUtils.read(file); Map map=new HashMap(); map.put("xsd","http://www.w3.org/2001/XMLSchema"); map.put("wsdl","http://schemas.xmlsoap.org/wsdl/"); map.put("soap","http://schemas.xmlsoap.org/wsdl/soap/"); XPathUtils util=new XPathUtils(map); Element node=(Element)util.getValueNode("//xsd:element[@name='arg0']",doc); assertNotNull(node); assertEquals("0",node.getAttribute("minOccurs")); assertTrue(node.getAttribute("type").contains("string")); }

Class: org.apache.cxf.tools.java2wsdl.JavaToWSFlagTest

EqualityVerifier 
@Test public void testNoArg(){ String[] args=new String[]{}; JavaToWS.main(args); assertEquals(-1,getStdOut().indexOf("Caused by:")); }

Class: org.apache.cxf.tools.java2wsdl.generator.wsdl11.DateTypeCustomGeneratorTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void getGetDateType(){ assertNull(gen.getDateType()); gen.setServiceModel(getServiceInfo(org.apache.cxf.tools.fortest.jaxws.rpc.GreeterFault.class)); assertNull(gen.getDateType()); gen.setServiceModel(getServiceInfo(EchoDate.class)); assertEquals(Date.class,gen.getDateType()); gen.setServiceModel(getServiceInfo(EchoCalendar.class)); assertEquals(Calendar.class,gen.getDateType()); }

InternalCallVerifier EqualityVerifier 
@Test public void testGenerateExternalStyle() throws Exception { gen.setAllowImports(true); gen.addSchemaFiles(Arrays.asList(new String[]{"hello_schema1.xsd","hello_schema2.xsd"})); gen.setWSDLName("date_external"); gen.setServiceModel(getServiceInfo(EchoDate.class)); assertEquals(Date.class,gen.getDateType()); URI expectedFile=getClass().getResource("expected/date.xjb").toURI(); assertFileEquals(new File(expectedFile),gen.generate(output)); gen.setWSDLName("calendar_external"); gen.setServiceModel(getServiceInfo(EchoCalendar.class)); assertEquals(Calendar.class,gen.getDateType()); expectedFile=getClass().getResource("expected/calendar.xjb").toURI(); assertFileEquals(new File(expectedFile),gen.generate(output)); }

InternalCallVerifier EqualityVerifier 
@Test public void testGenerateEmbedStyle() throws Exception { gen.setWSDLName("date_embed"); gen.setServiceModel(getServiceInfo(EchoDate.class)); assertEquals(Date.class,gen.getDateType()); URI expectedFile=getClass().getResource("expected/date_embed.xml").toURI(); assertFileEquals(new File(expectedFile),gen.generate(output)); gen.setWSDLName("calendar_embed"); gen.setServiceModel(getServiceInfo(EchoCalendar.class)); assertEquals(Calendar.class,gen.getDateType()); expectedFile=getClass().getResource("expected/calendar_embed.xml").toURI(); assertFileEquals(new File(expectedFile),gen.generate(output)); }

Class: org.apache.cxf.tools.java2wsdl.generator.wsdl11.FaultBeanGeneratorTest

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testGenFaultBean() throws Exception { String testingClass="org.apache.cxf.tools.fortest.cxf523.Database"; env.put(ToolConstants.CFG_CLASSNAME,testingClass); FaultBeanGenerator generator=new FaultBeanGenerator(); generator.setToolContext(env); generator.setServiceModel(getServiceInfo()); generator.generate(output); String pkgBase="org/apache/cxf/tools/fortest/cxf523/jaxws"; assertEquals(2,new File(output,pkgBase).listFiles().length); File faultBeanClass=new File(output,pkgBase + "/DBServiceFaultBean.java"); assertTrue(faultBeanClass.exists()); URI expectedFile=getClass().getResource("expected/DBServiceFaultBean.java.source").toURI(); assertFileEquals(new File(expectedFile),faultBeanClass); }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testGenFaultBeanWithCustomization() throws Exception { String testingClass="org.apache.cxf.tools.fortest.jaxws.rpc.GreeterFault"; env.put(ToolConstants.CFG_CLASSNAME,testingClass); FaultBeanGenerator generator=new FaultBeanGenerator(); generator.setServiceModel(getServiceInfo()); generator.setToolContext(env); generator.generate(output); String pkgBase="org/apache/cxf/tools/fortest/jaxws/rpc/types"; assertEquals(2,new File(output,pkgBase).listFiles().length); File faultBeanClass=new File(output,pkgBase + "/FaultDetail.java"); assertTrue(faultBeanClass.exists()); URI expectedFile=getClass().getResource("expected/FaultDetail.java.source").toURI(); assertFileEquals(new File(expectedFile),faultBeanClass); }

EqualityVerifier 
@Test public void testGetExceptionClasses() throws Exception { Class seiClass=Class.forName("org.apache.hello_world.Greeter"); FaultBeanGenerator generator=new FaultBeanGenerator(); Set> classes=new HashSet>(); for ( Method method : seiClass.getMethods()) { classes.addAll(generator.getExceptionClasses(method)); } assertEquals(0,classes.size()); classes.clear(); seiClass=Class.forName("org.apache.cxf.tools.fortest.cxf523.Database"); for ( Method method : seiClass.getMethods()) { classes.addAll(generator.getExceptionClasses(method)); } assertEquals(1,classes.size()); assertEquals("org.apache.cxf.tools.fortest.cxf523.DBServiceFault",classes.iterator().next().getName()); }

Class: org.apache.cxf.tools.java2wsdl.generator.wsdl11.annotator.WrapperBeanAnnotatorTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testAnnotate(){ String pkgName="org.apache.cxf.tools.fortest.withannotation.doc.jaxws"; WrapperBeanClass clz=new WrapperBeanClass(); clz.setFullClassName(pkgName + ".SayHi"); clz.setElementName(new QName("http://doc.withannotation.fortest.tools.cxf.apache.org/","sayHi")); clz.annotate(new WrapperBeanAnnotator()); List annotations=clz.getAnnotations(); String expectedNamespace="http://doc.withannotation.fortest.tools.cxf.apache.org/"; JAnnotation rootElementAnnotation=annotations.get(0); assertEquals("@XmlRootElement(name = \"sayHi\", " + "namespace = \"" + expectedNamespace + "\")",rootElementAnnotation.toString()); JAnnotation xmlTypeAnnotation=annotations.get(2); assertEquals("@XmlType(name = \"sayHi\", " + "namespace = \"" + expectedNamespace + "\")",xmlTypeAnnotation.toString()); JAnnotation accessorTypeAnnotation=annotations.get(1); assertEquals("@XmlAccessorType(XmlAccessType.FIELD)",accessorTypeAnnotation.toString()); WrapperBeanClass resWrapperClass=new WrapperBeanClass(); resWrapperClass.setFullClassName(pkgName + ".SayHiResponse"); resWrapperClass.setElementName(new QName(expectedNamespace,"sayHiResponse")); resWrapperClass.annotate(new WrapperBeanAnnotator()); annotations=resWrapperClass.getAnnotations(); rootElementAnnotation=annotations.get(0); assertEquals("@XmlRootElement(name = \"sayHiResponse\", " + "namespace = \"" + expectedNamespace + "\")",rootElementAnnotation.toString()); accessorTypeAnnotation=annotations.get(1); assertEquals("@XmlAccessorType(XmlAccessType.FIELD)",accessorTypeAnnotation.toString()); xmlTypeAnnotation=annotations.get(2); assertEquals("@XmlType(name = \"sayHiResponse\", " + "namespace = \"" + expectedNamespace + "\")",xmlTypeAnnotation.toString()); }

Class: org.apache.cxf.tools.java2wsdl.generator.wsdl11.annotator.WrapperBeanFieldAnnotatorTest

InternalCallVerifier EqualityVerifier 
@Test public void testAnnotate(){ JavaClass clz=new JavaClass(); clz.setFullClassName("org.apache.cxf.tools.fortest.withannotation.doc.jaxws.SayHi"); JavaField reqField=new JavaField("array","String[]","http://doc.withannotation.fortest.tools.cxf.apache.org/"); reqField.setOwner(clz); List annotation=reqField.getAnnotations(); assertEquals(0,annotation.size()); reqField.annotate(new WrapperBeanFieldAnnotator()); annotation=reqField.getAnnotations(); String expectedNamespace="http://doc.withannotation.fortest.tools.cxf.apache.org/"; assertEquals("@XmlElement(name = \"array\", namespace = \"" + expectedNamespace + "\")",annotation.get(0).toString()); clz.setFullClassName("org.apache.cxf.tools.fortest.withannotation.doc.jaxws.SayHiResponse"); JavaField resField=new JavaField("return","String[]","http://doc.withannotation.fortest.tools.cxf.apache.org/"); resField.setOwner(clz); resField.annotate(new WrapperBeanFieldAnnotator()); annotation=resField.getAnnotations(); assertEquals("@XmlElement(name = \"return\", namespace = \"" + expectedNamespace + "\")",annotation.get(0).toString()); }

Class: org.apache.cxf.tools.java2wsdl.processor.FrontendFactoryTest

InternalCallVerifier EqualityVerifier 
@Test public void testJaxwsStyle(){ factory.setServiceClass(Stock.class); assertEquals(FrontendFactory.Style.Jaxws,factory.discoverStyle()); }

InternalCallVerifier EqualityVerifier 
@Test public void testDefaultStyle(){ factory.setServiceClass(null); assertEquals(FrontendFactory.Style.Jaxws,factory.discoverStyle()); }

InternalCallVerifier EqualityVerifier 
@Test public void testSimpleStyle(){ factory.setServiceClass(Hello.class); assertEquals(FrontendFactory.Style.Simple,factory.discoverStyle()); }

Class: org.apache.cxf.tools.java2wsdl.processor.JavaToProcessorTest

InternalCallVerifier EqualityVerifier 
@Test public void testGetWSDLVersion(){ processor.setEnvironment(new ToolContext()); assertEquals(WSDLConstants.WSDLVersion.WSDL11,processor.getWSDLVersion()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testExceptionTypeAdapter() throws Exception { env.put(ToolConstants.CFG_OUTPUTFILE,output.getPath() + "/exception-type-adapter.wsdl"); env.put(ToolConstants.CFG_CLASSNAME,"org.apache.cxf.tools.fortest.exception.TypeAdapterEcho"); env.put(ToolConstants.CFG_VERBOSE,ToolConstants.CFG_VERBOSE); try { processor.setEnvironment(env); processor.process(); } catch ( Exception e) { e.printStackTrace(); } File wsdlFile=new File(output,"exception-type-adapter.wsdl"); assertTrue(wsdlFile.exists()); Document doc=StaxUtils.read(wsdlFile); Map map=new HashMap(); map.put("xsd","http://www.w3.org/2001/XMLSchema"); XPathUtils util=new XPathUtils(map); Node nd=util.getValueNode("//xsd:complexType[@name='myClass2']",doc); assertNotNull(nd); nd=util.getValueNode("//xsd:element[@name='adapted']",doc); assertNotNull(nd); String at=((Element)nd).getAttribute("type"); assertTrue(at.contains("myClass2")); assertEquals("0",((Element)nd).getAttribute("minOccurs")); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testTransientMessage() throws Exception { env.put(ToolConstants.CFG_OUTPUTFILE,output.getPath() + "/transient_message.wsdl"); env.put(ToolConstants.CFG_CLASSNAME,"org.apache.cxf.tools.fortest.exception.Echo4"); env.put(ToolConstants.CFG_VERBOSE,ToolConstants.CFG_VERBOSE); try { processor.setEnvironment(env); processor.process(); } catch ( Exception e) { e.printStackTrace(); } File wsdlFile=new File(output,"transient_message.wsdl"); assertTrue(wsdlFile.exists()); Document doc=StaxUtils.read(wsdlFile); Map map=new HashMap(); map.put("xsd","http://www.w3.org/2001/XMLSchema"); map.put("wsdl","http://schemas.xmlsoap.org/wsdl/"); map.put("soap","http://schemas.xmlsoap.org/wsdl/soap/"); map.put("tns","http://cxf.apache.org/test/HelloService"); XPathUtils util=new XPathUtils(map); String path="//xsd:complexType[@name='TransientMessageException']//xsd:sequence/xsd:element[@name='message']"; Element nd=(Element)util.getValueNode(path,doc); assertNull(nd); List sl=CastUtils.cast((List)env.get("serviceList")); FaultInfo mi=sl.get(0).getInterface().getOperation(new QName("http://cxf.apache.org/test/HelloService","echo")).getFault(new QName("http://cxf.apache.org/test/HelloService","TransientMessageException")); MessagePartInfo mpi=mi.getMessagePart(0); JAXBContext ctx=JAXBContext.newInstance(String.class,Integer.TYPE); StringWriter sw=new StringWriter(); XMLStreamWriter writer=StaxUtils.createXMLStreamWriter(sw); TransientMessageException tme=new TransientMessageException(12,"Exception Message"); Marshaller ms=ctx.createMarshaller(); ms.setProperty(Marshaller.JAXB_FRAGMENT,true); JAXBEncoderDecoder.marshallException(ms,tme,mpi,writer); writer.flush(); writer.close(); assertEquals(-1,sw.getBuffer().indexOf("Exception Message")); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetServiceName() throws Exception { processor.setEnvironment(env); assertNull(processor.getServiceName()); env.put(ToolConstants.CFG_SERVICENAME,"myservice"); processor.setEnvironment(env); assertEquals("myservice",processor.getServiceName()); }

EqualityVerifier 
@Test public void testResumeClasspath() throws Exception { File classFile=new java.io.File(output.getCanonicalPath() + "/classes"); String oldCP=System.getProperty("java.class.path"); env.put(ToolConstants.CFG_OUTPUTFILE,output.getPath() + "/hello.wsdl"); env.put(ToolConstants.CFG_CLASSNAME,"org.apache.cxf.tools.fortest.simple.Hello"); env.put(ToolConstants.CFG_CLASSPATH,classFile.toString()); processor.setEnvironment(env); processor.process(); String newCP=System.getProperty("java.class.path"); assertEquals(oldCP,newCP); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testExceptionList() throws Exception { env.put(ToolConstants.CFG_OUTPUTFILE,output.getPath() + "/exception_list.wsdl"); env.put(ToolConstants.CFG_CLASSNAME,"org.apache.cxf.tools.fortest.exception.Echo2Impl"); env.put(ToolConstants.CFG_VERBOSE,ToolConstants.CFG_VERBOSE); try { processor.setEnvironment(env); processor.process(); } catch ( Exception e) { e.printStackTrace(); } File wsdlFile=new File(output,"exception_list.wsdl"); assertTrue(wsdlFile.exists()); Document doc=StaxUtils.read(wsdlFile); Map map=new HashMap(); map.put("xsd","http://www.w3.org/2001/XMLSchema"); map.put("wsdl","http://schemas.xmlsoap.org/wsdl/"); map.put("soap","http://schemas.xmlsoap.org/wsdl/soap/"); XPathUtils util=new XPathUtils(map); Element nd=(Element)util.getValueNode("//xsd:element[@name='names']",doc); assertNotNull(nd); assertEquals("0",nd.getAttribute("minOccurs")); assertEquals("unbounded",nd.getAttribute("maxOccurs")); assertTrue(nd.getAttribute("type").endsWith(":myData")); nd=(Element)util.getValueNode("//xsd:complexType[@name='ListException2']" + "/xsd:sequence/xsd:element[@name='address']",doc); assertNotNull(nd); assertEquals("0",nd.getAttribute("minOccurs")); assertEquals("unbounded",nd.getAttribute("maxOccurs")); assertTrue(nd.getAttribute("type").endsWith(":myData")); }

Class: org.apache.cxf.tools.java2wsdl.processor.internal.jaxws.FaultBeanTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testTransform() throws Exception { Class faultClass=Class.forName("org.apache.cxf.tools.fortest.cxf523.DBServiceFault"); FaultBean bean=new FaultBean(); WrapperBeanClass beanClass=bean.transform(faultClass,"org.apache.cxf.tools.fortest.cxf523.jaxws"); assertNotNull(beanClass); assertEquals("DBServiceFaultBean",beanClass.getName()); assertEquals("org.apache.cxf.tools.fortest.cxf523.jaxws",beanClass.getPackageName()); assertEquals(1,beanClass.getFields().size()); JavaField field=beanClass.getFields().get(0); assertEquals("message",field.getName()); assertEquals("java.lang.String",field.getType()); QName qname=beanClass.getElementName(); assertEquals("DBServiceFault",qname.getLocalPart()); assertEquals("http://cxf523.fortest.tools.cxf.apache.org/",qname.getNamespaceURI()); }

Class: org.apache.cxf.tools.java2wsdl.processor.internal.jaxws.JaxwsServiceBuilderTest

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCXF669() throws Exception { boolean oldSetting=generator.allowImports(); generator.setAllowImports(true); builder.setServiceClass(org.apache.cxf.tools.fortest.cxf669.HelloImpl.class); ServiceInfo service=builder.createService(); assertNotNull(service); assertEquals(new QName("http://foo.com/HelloWorldService","HelloService"),service.getName()); assertEquals(new QName("http://foo.com/HelloWorld","HelloWorld"),service.getInterface().getName()); assertEquals(1,service.getSchemas().size()); assertEquals("http://foo.com/HelloWorld",service.getSchemas().iterator().next().getNamespaceURI()); Collection bindings=service.getBindings(); assertEquals(1,bindings.size()); assertEquals(new QName("http://foo.com/HelloWorldService","HelloServiceSoapBinding"),bindings.iterator().next().getName()); generator.setServiceModel(service); File wsdl=getOutputFile("HelloService.wsdl"); assertNotNull(wsdl); generator.generate(wsdl); assertTrue(wsdl.exists()); File logical=new File(output,"HelloWorld.wsdl"); assertTrue(logical.exists()); File schema=new File(output,"HelloService_schema1.xsd"); assertTrue(schema.exists()); String s=IOUtils.toString(new FileInputStream(wsdl)); assertTrue(s.indexOf("") != -1); assertTrue(s.indexOf("targetNamespace=\"http://foo.com/HelloWorldService\"") != -1); s=IOUtils.toString(new FileInputStream(logical)); assertTrue(s.indexOf("") != -1); assertTrue(s.indexOf("targetNamespace=\"http://foo.com/HelloWorld\"") != -1); s=IOUtils.toString(new FileInputStream(schema)); assertTrue(s.indexOf("targetNamespace=\"http://foo.com/HelloWorld\"") != -1); generator.setAllowImports(oldSetting); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testRpcLitNoSEI() throws Exception { builder.setServiceClass(org.apache.cxf.tools.fortest.withannotation.rpc.EchoImpl.class); ServiceInfo service=builder.createService(); assertNotNull(service); assertEquals(new QName("http://cxf.apache.org/echotest","EchoService"),service.getName()); assertEquals(new QName("http://cxf.apache.org/echotest","Echo"),service.getInterface().getName()); generator.setServiceModel(service); File output=getOutputFile("rpclist_no_sei.wsdl"); assertNotNull(output); generator.generate(output); assertTrue(output.exists()); String s=IOUtils.toString(new FileInputStream(output)); assertTrue(s.indexOf("EchoPort") != -1); URI expectedFile=this.getClass().getResource("expected/expected_rpclist_no_sei.wsdl").toURI(); assertWsdlEquals(new File(expectedFile),output); }

Class: org.apache.cxf.tools.java2wsdl.processor.internal.jaxws.RequestWrapperTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testWithAnnotationNoClass() throws Exception { String pkgName="org.apache.cxf.tools.fortest.withannotation.doc"; Class testingClass=Class.forName(pkgName + ".Stock"); OperationInfo opInfo=getOperation(testingClass,"getPrice"); Wrapper wrapper=new RequestWrapper(); wrapper.setOperationInfo(opInfo); assertFalse(wrapper.isWrapperAbsent()); assertTrue(wrapper.isToDifferentPackage()); assertFalse(wrapper.isWrapperBeanClassNotExist()); assertEquals(pkgName + ".jaxws",wrapper.getJavaClass().getPackageName()); assertEquals("GetPrice",wrapper.getJavaClass().getName()); }

InternalCallVerifier EqualityVerifier 
@Test public void testCXF1752() throws Exception { OperationInfo opInfo=getOperation(AddNumbersPortType.class,"testCXF1752"); RequestWrapper wrapper=new RequestWrapper(); wrapper.setOperationInfo(opInfo); wrapper.buildWrapperBeanClass(); List fields=wrapper.getJavaClass().getFields(); assertEquals(6,fields.size()); assertEquals("java.util.List",fields.get(0).getClassName()); assertEquals("byte[]",fields.get(2).getClassName()); assertEquals("org.apache.cxf.tools.fortest.xmllist.AddNumbersPortType.UserObject[]",fields.get(3).getClassName()); assertEquals("java.util.List",fields.get(4).getClassName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBuildRequestFields(){ Class testingClass=GreeterArray.class; OperationInfo opInfo=getOperation(testingClass,"sayStringArray"); assertNotNull(opInfo); RequestWrapper requestWrapper=new RequestWrapper(); MessageInfo message=opInfo.getUnwrappedOperation().getInput(); Method method=(Method)opInfo.getProperty("operation.method"); List fields=requestWrapper.buildFields(method,message); assertEquals(1,fields.size()); JavaField field=fields.get(0); assertEquals("arg0",field.getName()); assertEquals("String[]",field.getType()); opInfo=getOperation(testingClass,"sayIntArray"); assertNotNull(opInfo); message=opInfo.getUnwrappedOperation().getInput(); method=(Method)opInfo.getProperty("operation.method"); fields=requestWrapper.buildFields(method,message); assertEquals(1,fields.size()); field=fields.get(0); assertEquals("arg0",field.getName()); assertEquals("int[]",field.getType()); opInfo=getOperation(testingClass,"sayTestDataBeanArray"); assertNotNull(opInfo); message=opInfo.getUnwrappedOperation().getInput(); method=(Method)opInfo.getProperty("operation.method"); fields=requestWrapper.buildFields(method,message); assertEquals(1,fields.size()); field=fields.get(0); assertEquals("arg0",field.getName()); assertEquals("org.apache.cxf.tools.fortest.withannotation.doc.TestDataBean[]",field.getType()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testNoAnnotationNoClass() throws Exception { String pkgName="org.apache.cxf.tools.fortest.classnoanno.docwrapped"; Class testingClass=Class.forName(pkgName + ".Stock"); OperationInfo opInfo=getOperation(testingClass,"getPrice"); Wrapper wrapper=new RequestWrapper(); wrapper.setOperationInfo(opInfo); assertTrue(wrapper.isWrapperAbsent()); assertTrue(wrapper.isToDifferentPackage()); assertFalse(wrapper.isWrapperBeanClassNotExist()); assertEquals(pkgName + ".jaxws",wrapper.getJavaClass().getPackageName()); assertEquals("GetPrice",wrapper.getJavaClass().getName()); JavaClass jClass=wrapper.buildWrapperBeanClass(); assertNotNull(jClass); List jFields=jClass.getFields(); assertEquals(1,jFields.size()); assertEquals("arg0",jFields.get(0).getName()); assertEquals("java.lang.String",jFields.get(0).getClassName()); List jMethods=jClass.getMethods(); assertEquals(2,jMethods.size()); JavaMethod jMethod=jMethods.get(0); assertEquals("getArg0",jMethod.getName()); assertTrue(jMethod.getParameterListWithoutAnnotation().isEmpty()); jMethod=jMethods.get(1); assertEquals("setArg0",jMethod.getName()); assertEquals(1,jMethod.getParameterListWithoutAnnotation().size()); assertEquals("java.lang.String newArg0",jMethod.getParameterListWithoutAnnotation().get(0)); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testWithAnnotationWithClass() throws Exception { String pkgName="org.apache.cxf.tools.fortest.withannotation.doc"; Class testingClass=Class.forName(pkgName + ".Greeter"); OperationInfo opInfo=getOperation(testingClass,"sayHi"); Wrapper wrapper=new RequestWrapper(); wrapper.setOperationInfo(opInfo); assertFalse(wrapper.isWrapperAbsent()); assertTrue(wrapper.isToDifferentPackage()); assertFalse(wrapper.isWrapperBeanClassNotExist()); assertEquals(pkgName,wrapper.getJavaClass().getPackageName()); assertEquals("SayHi",wrapper.getJavaClass().getName()); }

Class: org.apache.cxf.tools.java2wsdl.processor.internal.jaxws.ResponseWrapperTest

InternalCallVerifier EqualityVerifier 
@Test public void testWithAnnotationWithClass() throws Exception { String pkgName="org.apache.cxf.tools.fortest.withannotation.doc"; Class testingClass=Class.forName(pkgName + ".Greeter"); OperationInfo opInfo=getOperation(testingClass,"sayHi"); Wrapper wrapper=new ResponseWrapper(); wrapper.setOperationInfo(opInfo); assertEquals(pkgName,wrapper.getJavaClass().getPackageName()); assertEquals("SayHiResponse",wrapper.getJavaClass().getName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBuildFields(){ Class testingClass=GreeterArray.class; OperationInfo opInfo=getOperation(testingClass,"sayStringArray"); assertNotNull(opInfo); ResponseWrapper responseWrapper=new ResponseWrapper(); MessageInfo message=opInfo.getUnwrappedOperation().getOutput(); Method method=(Method)opInfo.getProperty("operation.method"); JavaField field=responseWrapper.buildFields(method,message).get(0); assertEquals("_return",field.getParaName()); assertEquals("String[]",field.getType()); opInfo=getOperation(testingClass,"sayIntArray"); assertNotNull(opInfo); message=opInfo.getUnwrappedOperation().getOutput(); method=(Method)opInfo.getProperty("operation.method"); field=responseWrapper.buildFields(method,message).get(0); assertEquals("_return",field.getParaName()); assertEquals("int[]",field.getType()); opInfo=getOperation(testingClass,"sayTestDataBeanArray"); assertNotNull(opInfo); message=opInfo.getUnwrappedOperation().getOutput(); method=(Method)opInfo.getProperty("operation.method"); field=responseWrapper.buildFields(method,message).get(0); assertEquals("_return",field.getParaName()); assertEquals("org.apache.cxf.tools.fortest.withannotation.doc.TestDataBean[]",field.getType()); }

Class: org.apache.cxf.tools.java2wsdl.processor.internal.jaxws.WrapperTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testIsWrapperBeanClassNotExist() throws Exception { String pkgName="org.apache.cxf.tools.fortest.classnoanno.docwrapped"; Class stockClass=Class.forName(pkgName + ".Stock"); Method method=stockClass.getMethod("getPrice",String.class); Wrapper wrapper=new RequestWrapper(); wrapper.setMethod(method); assertTrue(wrapper.isWrapperAbsent()); assertTrue(wrapper.isToDifferentPackage()); assertFalse(wrapper.isWrapperBeanClassNotExist()); assertEquals(pkgName + ".jaxws",wrapper.getJavaClass().getPackageName()); assertEquals("GetPrice",wrapper.getJavaClass().getName()); pkgName="org.apache.cxf.tools.fortest.withannotation.doc"; stockClass=Class.forName(pkgName + ".Stock"); method=stockClass.getMethod("getPrice",String.class); wrapper=new RequestWrapper(); wrapper.setMethod(method); assertFalse(wrapper.isWrapperAbsent()); assertTrue(wrapper.isToDifferentPackage()); assertFalse(wrapper.isWrapperBeanClassNotExist()); assertEquals(pkgName + ".jaxws",wrapper.getJavaClass().getPackageName()); assertEquals("GetPrice",wrapper.getJavaClass().getName()); pkgName="org.apache.cxf.tools.fortest.withannotation.doc"; Class clz=Class.forName(pkgName + ".Greeter"); method=clz.getMethod("sayHi"); wrapper=new RequestWrapper(); wrapper.setMethod(method); assertFalse(wrapper.isWrapperAbsent()); assertTrue(wrapper.isToDifferentPackage()); assertFalse(wrapper.isWrapperBeanClassNotExist()); assertEquals(pkgName,wrapper.getJavaClass().getPackageName()); assertEquals("SayHi",wrapper.getJavaClass().getName()); wrapper=new ResponseWrapper(); wrapper.setMethod(method); assertEquals(pkgName,wrapper.getJavaClass().getPackageName()); assertEquals("SayHiResponse",wrapper.getJavaClass().getName()); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetWrapperBeanClassFromQName(){ QName qname=new QName("http://cxf.apache.org","sayHi"); Wrapper wrapper=new Wrapper(); wrapper.setName(qname); JavaClass jClass=wrapper.getWrapperBeanClass(qname); assertEquals("org.apache.cxf",jClass.getPackageName()); assertEquals("SayHi",jClass.getName()); assertEquals("http://cxf.apache.org",jClass.getNamespace()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetWrapperBeanClassFromMethod() throws Exception { String pkgName="org.apache.cxf.tools.fortest.classnoanno.docwrapped"; Class stockClass=Class.forName(pkgName + ".Stock"); Method method=stockClass.getMethod("getPrice",String.class); Wrapper wrapper=new Wrapper(); wrapper.setMethod(method); JavaClass jClass=wrapper.getWrapperBeanClass(method); assertNotNull(jClass); assertNull(jClass.getPackageName()); assertNull(jClass.getName()); wrapper=new RequestWrapper(); jClass=wrapper.getWrapperBeanClass(method); assertEquals("GetPrice",jClass.getName()); assertEquals(pkgName + ".jaxws",jClass.getPackageName()); wrapper=new ResponseWrapper(); jClass=wrapper.getWrapperBeanClass(method); assertEquals("GetPriceResponse",jClass.getName()); assertEquals(pkgName + ".jaxws",jClass.getPackageName()); }

Class: org.apache.cxf.tools.misc.processor.WSDLToServiceProcessorTest

APIUtilityVerifier IterativeVerifier BranchVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testNewServiceSoap12() throws Exception { String[] args=new String[]{"-soap12","-transport","soap","-e","SOAPService","-p","SoapPort","-n","Greeter_SOAPBinding","-a","http://localhost:9000/SOAPService/SoapPort","-d",output.getCanonicalPath(),getLocation("/misctools_wsdl/hello_world_soap12.wsdl")}; WSDLToService.main(args); File outputFile=new File(output,"hello_world_soap12-service.wsdl"); assertTrue("New wsdl file is not generated",outputFile.exists()); WSDLToServiceProcessor processor=new WSDLToServiceProcessor(); processor.setEnvironment(env); try { processor.parseWSDL(outputFile.getAbsolutePath()); Service service=processor.getWSDLDefinition().getService(new QName(processor.getWSDLDefinition().getTargetNamespace(),"SOAPService")); if (service == null) { fail("Element wsdl:service serviceins Missed!"); } Iterator it=service.getPort("SoapPort").getExtensibilityElements().iterator(); if (it == null || !it.hasNext()) { fail("Element wsdl:port portins Missed!"); } while (it.hasNext()) { Object obj=it.next(); if (obj instanceof SOAP12Address) { SOAP12Address soapAddress=(SOAP12Address)obj; assertNotNull(soapAddress.getLocationURI()); assertEquals("http://localhost:9000/SOAPService/SoapPort",soapAddress.getLocationURI()); break; } } } catch ( ToolException e) { fail("Exception Encountered when parsing wsdl, error: " + e.getMessage()); } }

Class: org.apache.cxf.tools.misc.processor.WSDLToSoapProcessorTest

APIUtilityVerifier BranchVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testDocLitWithFault() throws Exception { String[] args=new String[]{"-i","Greeter","-d",output.getCanonicalPath(),getLocation("/misctools_wsdl/hello_world_doc_lit.wsdl")}; WSDLToSoap.main(args); File outputFile=new File(output,"hello_world_doc_lit-soapbinding.wsdl"); assertTrue("New wsdl file is not generated",outputFile.exists()); WSDLToSoapProcessor processor=new WSDLToSoapProcessor(); processor.setEnvironment(env); try { processor.parseWSDL(outputFile.getAbsolutePath()); Binding binding=processor.getWSDLDefinition().getBinding(new QName(processor.getWSDLDefinition().getTargetNamespace(),"Greeter_Binding")); if (binding == null) { fail("Element wsdl:binding Greeter_Binding Missed!"); } boolean found=false; for ( Object obj : binding.getExtensibilityElements()) { SoapBinding soapBinding=SOAPBindingUtil.getSoapBinding(obj); if (soapBinding != null && soapBinding.getStyle().equalsIgnoreCase("document")) { found=true; break; } } if (!found) { fail("Element soap:binding Missed!"); } BindingOperation bo=binding.getBindingOperation("pingMe",null,null); if (bo == null) { fail("Element Missed!"); } found=false; for ( Object obj : bo.getExtensibilityElements()) { SoapOperation soapOperation=SOAPBindingUtil.getSoapOperation(obj); if (soapOperation != null && soapOperation.getStyle().equalsIgnoreCase("document")) { found=true; break; } } if (!found) { fail("Element soap:operation Missed!"); } BindingFault fault=bo.getBindingFault("pingMeFault"); if (fault == null) { fail("Element Missed!"); } found=false; for ( Object obj : fault.getExtensibilityElements()) { if (SOAPBindingUtil.isSOAPFault(obj)) { found=true; break; } } if (!found) { fail("Element soap:fault Missed!"); } List faults=SOAPBindingUtil.getBindingOperationSoapFaults(bo); assertEquals(1,faults.size()); assertEquals("pingMeFault",faults.get(0).getName()); } catch ( ToolException e) { fail("Exception Encountered when parsing wsdl, error: " + e.getMessage()); } }

APIUtilityVerifier BranchVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAddSoap12Binding() throws Exception { String[] args=new String[]{"-i","Greeter","-soap12","-b","Greeter_SOAP12Binding","-d",output.getCanonicalPath(),"-o","hello_world_soap12_newbinding.wsdl",getLocation("/misctools_wsdl/hello_world_soap12.wsdl")}; WSDLToSoap.main(args); File outputFile=new File(output,"hello_world_soap12_newbinding.wsdl"); assertTrue("New wsdl file is not generated",outputFile.exists()); WSDLToSoapProcessor processor=new WSDLToSoapProcessor(); processor.setEnvironment(env); try { processor.parseWSDL(outputFile.getAbsolutePath()); Binding binding=processor.getWSDLDefinition().getBinding(new QName(processor.getWSDLDefinition().getTargetNamespace(),"Greeter_SOAP12Binding")); if (binding == null) { fail("Element wsdl:binding Greeter_SOAPBinding_NewBinding Missed!"); } for ( Object obj : binding.getExtensibilityElements()) { assertTrue(SOAPBindingUtil.isSOAPBinding(obj)); assertTrue(obj instanceof SOAP12Binding); SoapBinding soapBinding=SOAPBindingUtil.getSoapBinding(obj); assertNotNull(soapBinding); assertTrue("document".equalsIgnoreCase(soapBinding.getStyle())); } BindingOperation bo=binding.getBindingOperation("sayHi",null,null); if (bo == null) { fail("Element Missed!"); } for ( Object obj : bo.getExtensibilityElements()) { assertTrue(SOAPBindingUtil.isSOAPOperation(obj)); assertTrue(obj instanceof SOAP12Operation); SoapOperation soapOperation=SOAPBindingUtil.getSoapOperation(obj); assertNotNull(soapOperation); assertTrue("document".equalsIgnoreCase(soapOperation.getStyle())); } BindingInput bi=bo.getBindingInput(); for ( Object obj : bi.getExtensibilityElements()) { assertTrue(SOAPBindingUtil.isSOAPBody(obj)); assertTrue(obj instanceof SOAP12Body); SoapBody soapBody=SOAPBindingUtil.getSoapBody(obj); assertNotNull(soapBody); assertTrue("literal".equalsIgnoreCase(soapBody.getUse())); } bo=binding.getBindingOperation("pingMe",null,null); assertNotNull(bo); Iterator it=bo.getExtensibilityElements().iterator(); assertTrue(it != null && it.hasNext()); assertTrue(it.next() instanceof SOAP12Operation); it=bo.getBindingInput().getExtensibilityElements().iterator(); assertTrue(it != null && it.hasNext()); assertTrue(it.next() instanceof SOAP12Body); it=bo.getBindingOutput().getExtensibilityElements().iterator(); assertTrue(it != null && it.hasNext()); assertTrue(it.next() instanceof SOAP12Body); Map faults=bo.getBindingFaults(); assertTrue(faults != null && faults.size() == 1); Object bf=faults.get("pingMeFault"); assertNotNull(bf); assertTrue(bf instanceof BindingFault); assertEquals("pingMeFault",((BindingFault)bf).getName()); } catch ( ToolException e) { fail("Exception Encountered when parsing wsdl, error: " + e.getMessage()); } }

Class: org.apache.cxf.tools.util.BuiltInTypesJavaMappingUtilTest

APIUtilityVerifier EqualityVerifier 
@Test public void testGetJType(){ String jType=BuiltInTypesJavaMappingUtil.getJType(xmlSchemaNS,"string"); assertEquals(jType,"java.lang.String"); }

Class: org.apache.cxf.tools.util.NameUtilTest

EqualityVerifier 
@Test public void testMangleToClassName(){ assertEquals("Abc100Xyz",NameUtil.mangleNameToClassName("abc100xyz")); assertEquals("NameUtilTest",NameUtil.mangleNameToClassName("name_util_test")); assertEquals("NameUtil",NameUtil.mangleNameToClassName("nameUtil")); assertEquals("Int",NameUtil.mangleNameToClassName("int")); }

EqualityVerifier 
@Test public void testMangleToVariableName(){ assertEquals("abc100Xyz",NameUtil.mangleNameToVariableName("abc100xyz")); assertEquals("nameUtilTest",NameUtil.mangleNameToVariableName("name_util_test")); assertEquals("nameUtil",NameUtil.mangleNameToVariableName("NameUtil")); assertEquals("int",NameUtil.mangleNameToVariableName("int")); }

Class: org.apache.cxf.tools.util.StAXUtilTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetTags() throws Exception { File file=new File(getClass().getResource("resources/test.wsdl").toURI()); file=getResource("resources/test2.wsdl"); Tag tag1=ToolsStaxUtils.getTagTree(file); assertEquals(1,tag1.getTags().size()); Tag def1=tag1.getTags().get(0); assertEquals(6,def1.getTags().size()); Tag types1=def1.getTags().get(0); Tag schema1=types1.getTags().get(0); assertEquals(4,schema1.getTags().size()); file=getResource("resources/test3.wsdl"); Tag tag2=ToolsStaxUtils.getTagTree(file); assertEquals(1,tag2.getTags().size()); Tag def2=tag2.getTags().get(0); assertEquals(6,def2.getTags().size()); Tag types2=def2.getTags().get(0); Tag schema2=types2.getTags().get(0); assertEquals(4,schema2.getTags().size()); assertTagEquals(schema1,schema2); }

Class: org.apache.cxf.tools.util.URIParserUtilTest

EqualityVerifier 
@Test public void testGetPackageName(){ String packageName=URIParserUtil.getPackageName("http://www.cxf.iona.com"); assertEquals(packageName,"com.iona.cxf"); packageName=URIParserUtil.getPackageName("urn://www.class.iona.com"); assertEquals(packageName,"com.iona._class"); }

EqualityVerifier 
@Test public void testNormalize() throws Exception { String uri="wsdl/hello_world.wsdl"; assertEquals("file:wsdl/hello_world.wsdl",URIParserUtil.normalize(uri)); uri="\\src\\wsdl/hello_world.wsdl"; assertEquals("file:/src/wsdl/hello_world.wsdl",URIParserUtil.normalize(uri)); uri="wsdl\\hello_world.wsdl"; assertEquals("file:wsdl/hello_world.wsdl",URIParserUtil.normalize(uri)); uri="http://hello.com"; assertEquals("http://hello.com",URIParserUtil.normalize(uri)); uri="file:///c:\\hello.wsdl"; assertEquals("file:/c:/hello.wsdl",URIParserUtil.normalize(uri)); uri="c:\\hello.wsdl"; assertEquals("file:/c:/hello.wsdl",URIParserUtil.normalize(uri)); uri="/c:\\hello.wsdl"; assertEquals("file:/c:/hello.wsdl",URIParserUtil.normalize(uri)); uri="file:/home/john/test/all/../../alltest"; assertEquals("file:/home/john/alltest",URIParserUtil.normalize(uri)); }

APIUtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetAbsoluteURI() throws Exception { String uri="wsdl/hello_world.wsdl"; String uri2=URIParserUtil.getAbsoluteURI(uri); assertNotNull(uri2); assertTrue(uri2.startsWith("file")); assertTrue(uri2.contains(uri)); assertTrue(uri2.contains(new java.io.File("").toString())); uri=getClass().getResource("/schemas/wsdl/test.xsd").toString(); uri2=URIParserUtil.getAbsoluteURI(uri); assertNotNull(uri2); assertTrue(uri2.startsWith("file")); assertTrue(uri2.contains(uri)); assertTrue(uri2.contains(new java.io.File("").toString())); uri="c:\\wsdl\\hello_world.wsdl"; uri2=URIParserUtil.getAbsoluteURI(uri); assertNotNull(uri2); assertEquals("file:/c:/wsdl/hello_world.wsdl",uri2); uri="/c:\\wsdl\\hello_world.wsdl"; uri2=URIParserUtil.getAbsoluteURI(uri); assertNotNull(uri2); assertEquals("file:/c:/wsdl/hello_world.wsdl",uri2); uri="http://hello/world.wsdl"; assertEquals(uri,URIParserUtil.getAbsoluteURI(uri)); uri="file:/home/john/test/all/../../alltest"; assertEquals("file:/home/john/alltest",URIParserUtil.getAbsoluteURI(uri)); }

APIUtilityVerifier EqualityVerifier 
@Test public void testCXF3855() throws Exception { String orig=new String(new byte[]{-47,-122},StandardCharsets.UTF_8); orig="/foo" + orig + ".txt"; String s=URIParserUtil.escapeChars(orig); assertEquals(orig,URLDecoder.decode(s,StandardCharsets.UTF_8.name())); }

Class: org.apache.cxf.tools.validator.internal.WSDLRefValidatorTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testLogicalWSDL() throws Exception { String wsdl=getClass().getResource("resources/logical.wsdl").toURI().toString(); WSDLRefValidator validator=new WSDLRefValidator(getWSDL(wsdl),null); validator.isValid(); ValidationResult results=validator.getValidationResults(); assertEquals(1,results.getErrors().size()); String text="{http://schemas.apache.org/yoko/idl/OptionsPT}[message:getEmployee]"; Set possibles=new HashSet(); possibles.add(new Message("FAILED_AT_POINT",WSDLRefValidator.LOG,42,6,new java.net.URI(wsdl).toURL(),text).toString()); possibles.add(new Message("FAILED_AT_POINT",WSDLRefValidator.LOG,42,70,new java.net.URI(wsdl).toURL(),text).toString()); possibles.add(new Message("FAILED_AT_POINT",WSDLRefValidator.LOG,-1,-1,new java.net.URI(wsdl).toURL(),text).toString()); assertTrue(possibles.contains(results.getErrors().pop())); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testNoTypeRef() throws Exception { String wsdl=getClass().getResource("resources/NoTypeRef.wsdl").toURI().toString(); WSDLRefValidator validator=new WSDLRefValidator(getWSDL(wsdl),null); assertFalse(validator.isValid()); assertEquals(3,validator.getValidationResults().getErrors().size()); String expected="Part in Message " + "<{http://apache.org/samples/headers}inHeaderRequest>" + " referenced Type <{http://apache.org/samples/headers}SOAPHeaderInfo> "+ "can not be found in the schemas"; String t=null; while (!validator.getValidationResults().getErrors().empty()) { t=validator.getValidationResults().getErrors().pop(); if (expected.equals(t)) { break; } } assertEquals(expected,t); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testWSDLImport1() throws Exception { String wsdl=getClass().getResource("resources/a.wsdl").toURI().toString(); WSDLRefValidator validator=new WSDLRefValidator(getWSDL(wsdl),null); validator.isValid(); ValidationResult results=validator.getValidationResults(); assertEquals(2,results.getErrors().size()); String t=results.getErrors().pop(); String text="{http://apache.org/hello_world/messages}[portType:GreeterA][operation:sayHi]"; Set possibles=new HashSet(); possibles.add(new Message("FAILED_AT_POINT",WSDLRefValidator.LOG,27,2,new java.net.URI(wsdl).toURL(),text).toString()); possibles.add(new Message("FAILED_AT_POINT",WSDLRefValidator.LOG,27,31,new java.net.URI(wsdl).toURL(),text).toString()); possibles.add(new Message("FAILED_AT_POINT",WSDLRefValidator.LOG,-1,-1,new java.net.URI(wsdl).toURL(),text).toString()); assertTrue(possibles.contains(t)); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testNoService() throws Exception { String wsdl=getClass().getResource("resources/b.wsdl").toURI().toString(); WSDLRefValidator validator=new WSDLRefValidator(getWSDL(wsdl),null); assertFalse(validator.isValid()); ValidationResult results=validator.getValidationResults(); assertEquals(0,results.getWarnings().size()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testNoBindingWSDL() throws Exception { String wsdl=getClass().getResource("resources/nobinding.wsdl").toURI().toString(); WSDLRefValidator validator=new WSDLRefValidator(getWSDL(wsdl),null); validator.isValid(); ValidationResult results=validator.getValidationResults(); assertEquals(0,results.getWarnings().size()); WSDLRefValidator v=new WSDLRefValidator(getWSDL(wsdl),null); v.setSuppressWarnings(true); assertTrue(v.isValid()); }

Class: org.apache.cxf.tools.validator.internal.model.XNodeTest

InternalCallVerifier EqualityVerifier 
@Test public void testGetXPath(){ XNode node=new XNode(); node.setQName(WSDLConstants.QNAME_BINDING); node.setPrefix("wsdl"); node.setAttributeName("name"); node.setAttributeValue("SOAPBinding"); assertEquals("/wsdl:binding[@name='SOAPBinding']",node.toString()); assertEquals("[binding:SOAPBinding]",node.getPlainText()); }

InternalCallVerifier EqualityVerifier 
@Test public void testParentNode(){ XDef definition=new XDef(); String ns="{http://apache.org/hello_world/messages}"; definition.setTargetNamespace("http://apache.org/hello_world/messages"); assertEquals(ns,definition.getPlainText()); XPortType portType=new XPortType(); portType.setName("Greeter"); portType.setParentNode(definition); String portTypeText=ns + "[portType:Greeter]"; assertEquals(portTypeText,portType.getPlainText()); XOperation op=new XOperation(); op.setName("sayHi"); op.setParentNode(portType); assertEquals(portTypeText + "[operation:sayHi]",op.getPlainText()); String expected="/wsdl:definitions[@targetNamespace='http://apache.org/hello_world/messages']"; expected+="/wsdl:portType[@name='Greeter']/wsdl:operation[@name='sayHi']"; assertEquals(expected,op.toString()); }

EqualityVerifier 
@Test public void testWSDLDefinition(){ XDef def=new XDef(); assertEquals("/wsdl:definitions",def.toString()); }

Class: org.apache.cxf.tools.wadlto.jaxrs.JAXRSContainerTest

UtilityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testInheritParameters(){ try { JAXRSContainer container=new JAXRSContainer(null); ToolContext context=new ToolContext(); context.put(WadlToolConstants.CFG_OUTPUTDIR,output.getCanonicalPath()); context.put(WadlToolConstants.CFG_WADLURL,getLocation("/wadl/test.xml")); context.put(WadlToolConstants.CFG_COMPILE,"true"); context.put(WadlToolConstants.CFG_SCHEMA_TYPE_MAP,"{http://www.w3.org/2001/XMLSchema}anyType=" + "java.io.InputStream"); context.put(WadlToolConstants.CFG_INHERIT_PARAMS,"last"); context.put(WadlToolConstants.CFG_CREATE_JAVA_DOCS,"true"); container.setContext(context); container.execute(); assertNotNull(output.list()); List files=FileUtils.getFilesRecurse(output,".+\\." + "class" + "$"); assertEquals(1,files.size()); } catch ( Exception e) { e.printStackTrace(); fail(); } }

UtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCodeGenNoIds2(){ try { JAXRSContainer container=new JAXRSContainer(null); ToolContext context=new ToolContext(); context.put(WadlToolConstants.CFG_OUTPUTDIR,output.getCanonicalPath()); context.put(WadlToolConstants.CFG_WADLURL,getLocation("/wadl/multipleResources.xml")); context.put(WadlToolConstants.CFG_COMPILE,"true"); container.setContext(context); container.execute(); assertNotNull(output.list()); List javaFiles=FileUtils.getFilesRecurse(output,".+\\." + "java" + "$"); assertEquals(2,javaFiles.size()); assertTrue(checkContains(javaFiles,"application.BookstoreResource.java")); assertTrue(checkContains(javaFiles,"application.BooksResource.java")); List classFiles=FileUtils.getFilesRecurse(output,".+\\." + "class" + "$"); assertEquals(2,classFiles.size()); assertTrue(checkContains(classFiles,"application.BookstoreResource.class")); assertTrue(checkContains(classFiles,"application.BooksResource.class")); } catch ( Exception e) { e.printStackTrace(); fail(); } }

UtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCodeGenNoIds3(){ try { JAXRSContainer container=new JAXRSContainer(null); ToolContext context=new ToolContext(); context.put(WadlToolConstants.CFG_OUTPUTDIR,output.getCanonicalPath()); context.put(WadlToolConstants.CFG_WADLURL,getLocation("/wadl/resourcesNoId.xml")); context.put(WadlToolConstants.CFG_COMPILE,"true"); context.put(WadlToolConstants.CFG_INHERIT_PARAMS,"true"); container.setContext(context); container.execute(); assertNotNull(output.list()); List javaFiles=FileUtils.getFilesRecurse(output,".+\\." + "java" + "$"); assertEquals(1,javaFiles.size()); assertTrue(checkContains(javaFiles,"application.TestRsResource.java")); List classFiles=FileUtils.getFilesRecurse(output,".+\\." + "class" + "$"); assertEquals(1,classFiles.size()); assertTrue(checkContains(classFiles,"application.TestRsResource.class")); } catch ( Exception e) { e.printStackTrace(); fail(); } }

APIUtilityVerifier UtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testComplexPath(){ try { JAXRSContainer container=new JAXRSContainer(null); ToolContext context=new ToolContext(); context.put(WadlToolConstants.CFG_OUTPUTDIR,output.getCanonicalPath()); context.put(WadlToolConstants.CFG_WADLURL,getLocation("/wadl/testComplexPath.xml")); context.put(WadlToolConstants.CFG_COMPILE,"true"); container.setContext(context); container.execute(); assertNotNull(output.list()); List files=FileUtils.getFilesRecurse(output,".+\\." + "class" + "$"); assertEquals(1,files.size()); assertTrue(checkContains(files,"application.Resource.class")); @SuppressWarnings("resource") ClassLoader loader=new URLClassLoader(new URL[]{output.toURI().toURL()}); Class test1=loader.loadClass("application.Resource"); Method[] test1Methods=test1.getDeclaredMethods(); assertEquals(2,test1Methods.length); assertEquals(2,test1Methods[0].getAnnotations().length); checkComplexPathMethod(test1Methods[0],""); checkComplexPathMethod(test1Methods[1],"2"); } catch ( Exception e) { e.printStackTrace(); fail(); } }

UtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testResourceWithEPRNoSchemaGen(){ try { JAXRSContainer container=new JAXRSContainer(null); ToolContext context=new ToolContext(); context.put(WadlToolConstants.CFG_OUTPUTDIR,output.getCanonicalPath()); context.put(WadlToolConstants.CFG_WADLURL,getLocation("/wadl/resourceWithEPR.xml")); context.put(WadlToolConstants.CFG_SCHEMA_TYPE_MAP,"{http://www.w3.org/2005/08/addressing}EndpointReferenceType=" + "javax.xml.ws.wsaddressing.W3CEndpointReference"); context.put(WadlToolConstants.CFG_NO_ADDRESS_BINDING,"true"); context.put(WadlToolConstants.CFG_NO_TYPES,"true"); context.put(WadlToolConstants.CFG_COMPILE,"true"); container.setContext(context); container.execute(); assertNotNull(output.list()); List files=FileUtils.getFilesRecurse(output,".+\\." + "class" + "$"); assertEquals(1,files.size()); assertTrue(checkContains(files,"application" + ".BookstoreResource.class")); } catch ( Exception e) { e.printStackTrace(); fail(); } }

UtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCodeGenWithResourceSet(){ try { JAXRSContainer container=new JAXRSContainer(null); ToolContext context=new ToolContext(); context.put(WadlToolConstants.CFG_OUTPUTDIR,output.getCanonicalPath()); context.put(WadlToolConstants.CFG_WADLURL,getLocation("/wadl/singleResourceWithRefs.xml")); context.put(WadlToolConstants.CFG_RESOURCENAME,"CustomResource"); context.put(WadlToolConstants.CFG_COMPILE,"true"); container.setContext(context); container.execute(); assertNotNull(output.list()); List javaFiles=FileUtils.getFilesRecurse(output,".+\\." + "java" + "$"); assertEquals(1,javaFiles.size()); assertTrue(checkContains(javaFiles,"application.CustomResource.java")); List classFiles=FileUtils.getFilesRecurse(output,".+\\." + "class" + "$"); assertEquals(1,classFiles.size()); assertTrue(checkContains(classFiles,"application.CustomResource.class")); } catch ( Exception e) { e.printStackTrace(); fail(); } }

APIUtilityVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testQueryMultipartParam(){ try { JAXRSContainer container=new JAXRSContainer(null); ToolContext context=new ToolContext(); context.put(WadlToolConstants.CFG_OUTPUTDIR,output.getCanonicalPath()); context.put(WadlToolConstants.CFG_WADLURL,getLocation("/wadl/testQueryMultipartParam.wadl")); context.put(WadlToolConstants.CFG_COMPILE,"true"); container.setContext(context); container.execute(); assertNotNull(output.list()); List files=FileUtils.getFilesRecurse(output,".+\\." + "class" + "$"); assertEquals(2,files.size()); assertTrue(checkContains(files,"application.Test1.class")); assertTrue(checkContains(files,"application.Test2.class")); @SuppressWarnings("resource") ClassLoader loader=new URLClassLoader(new URL[]{output.toURI().toURL()}); Class test1=loader.loadClass("application.Test1"); Method[] test1Methods=test1.getDeclaredMethods(); assertEquals(1,test1Methods.length); assertEquals(2,test1Methods[0].getAnnotations().length); assertNotNull(test1Methods[0].getAnnotation(PUT.class)); Consumes consumes1=test1Methods[0].getAnnotation(Consumes.class); assertNotNull(consumes1); assertEquals(1,consumes1.value().length); assertEquals("multipart/mixed",consumes1.value()[0]); assertEquals("put",test1Methods[0].getName()); Class[] paramTypes=test1Methods[0].getParameterTypes(); assertEquals(3,paramTypes.length); Annotation[][] paramAnns=test1Methods[0].getParameterAnnotations(); assertEquals(Boolean.class,paramTypes[0]); assertEquals(1,paramAnns[0].length); QueryParam test1QueryParam1=(QueryParam)paramAnns[0][0]; assertEquals("standalone",test1QueryParam1.value()); assertEquals(String.class,paramTypes[1]); assertEquals(1,paramAnns[1].length); Multipart test1MultipartParam1=(Multipart)paramAnns[1][0]; assertEquals("action",test1MultipartParam1.value()); assertTrue(test1MultipartParam1.required()); assertEquals(String.class,paramTypes[2]); assertEquals(1,paramAnns[2].length); Multipart test1MultipartParam2=(Multipart)paramAnns[2][0]; assertEquals("sources",test1MultipartParam2.value()); assertFalse(test1MultipartParam2.required()); Class test2=loader.loadClass("application.Test2"); Method[] test2Methods=test2.getDeclaredMethods(); assertEquals(1,test2Methods.length); assertEquals(2,test2Methods[0].getAnnotations().length); assertNotNull(test2Methods[0].getAnnotation(PUT.class)); Consumes consumes2=test2Methods[0].getAnnotation(Consumes.class); assertNotNull(consumes2); assertEquals(1,consumes2.value().length); assertEquals("application/json",consumes2.value()[0]); assertEquals("put",test2Methods[0].getName()); Class[] paramTypes2=test2Methods[0].getParameterTypes(); assertEquals(2,paramTypes2.length); Annotation[][] paramAnns2=test2Methods[0].getParameterAnnotations(); assertEquals(boolean.class,paramTypes2[0]); assertEquals(1,paramAnns2[0].length); QueryParam test2QueryParam1=(QueryParam)paramAnns2[0][0]; assertEquals("snapshot",test2QueryParam1.value()); assertEquals(String.class,paramTypes2[1]); assertEquals(0,paramAnns2[1].length); } catch ( Exception e) { e.printStackTrace(); fail(); } }

UtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCodeGenNoIds(){ try { JAXRSContainer container=new JAXRSContainer(null); ToolContext context=new ToolContext(); context.put(WadlToolConstants.CFG_OUTPUTDIR,output.getCanonicalPath()); context.put(WadlToolConstants.CFG_WADLURL,getLocation("/wadl/singleResource.xml")); context.put(WadlToolConstants.CFG_RESOURCENAME,"CustomResource"); context.put(WadlToolConstants.CFG_GENERATE_ENUMS,"true"); context.put(WadlToolConstants.CFG_COMPILE,"true"); container.setContext(context); container.execute(); assertNotNull(output.list()); List javaFiles=FileUtils.getFilesRecurse(output,".+\\." + "java" + "$"); assertEquals(2,javaFiles.size()); assertTrue(checkContains(javaFiles,"application.CustomResource.java")); assertTrue(checkContains(javaFiles,"application.Theid.java")); List classFiles=FileUtils.getFilesRecurse(output,".+\\." + "class" + "$"); assertEquals(2,classFiles.size()); assertTrue(checkContains(classFiles,"application.CustomResource.class")); assertTrue(checkContains(classFiles,"application.Theid.class")); } catch ( Exception e) { e.printStackTrace(); fail(); } }

UtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testNoTargetNamespace(){ try { JAXRSContainer container=new JAXRSContainer(null); ToolContext context=new ToolContext(); context.put(WadlToolConstants.CFG_OUTPUTDIR,output.getCanonicalPath()); context.put(WadlToolConstants.CFG_WADLURL,getLocation("/wadl/resourceSchemaNoTargetNamespace.xml")); context.put(WadlToolConstants.CFG_SCHEMA_PACKAGENAME,"=custom"); context.put(WadlToolConstants.CFG_COMPILE,"true"); container.setContext(context); container.execute(); assertNotNull(output.list()); List files=FileUtils.getFilesRecurse(output,".+\\.class" + "$"); assertEquals(3,files.size()); assertTrue(checkContains(files,"application" + ".Resource.class")); assertTrue(checkContains(files,"custom" + ".TestCompositeObject.class")); assertTrue(checkContains(files,"custom" + ".ObjectFactory.class")); } catch ( Exception e) { e.printStackTrace(); fail(); } }

UtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testResourceWithEPR(){ try { JAXRSContainer container=new JAXRSContainer(null); ToolContext context=new ToolContext(); context.put(WadlToolConstants.CFG_OUTPUTDIR,output.getCanonicalPath()); context.put(WadlToolConstants.CFG_WADLURL,getLocation("/wadl/resourceWithEPR.xml")); context.put(WadlToolConstants.CFG_SCHEMA_TYPE_MAP,"{http://www.w3.org/2001/XMLSchema}date=javax.xml.datatype.XMLGregorianCalendar"); context.put(WadlToolConstants.CFG_COMPILE,"true"); container.setContext(context); container.execute(); assertNotNull(output.list()); List files=FileUtils.getFilesRecurse(output,".+\\." + "class" + "$"); assertEquals(4,files.size()); assertTrue(checkContains(files,"application" + ".BookstoreResource.class")); assertTrue(checkContains(files,"superbooks" + ".Book.class")); assertTrue(checkContains(files,"superbooks" + ".ObjectFactory.class")); assertTrue(checkContains(files,"superbooks" + ".package-info.class")); } catch ( Exception e) { e.printStackTrace(); fail(); } }

UtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCodeTwoSchemasSameTargetNs(){ try { JAXRSContainer container=new JAXRSContainer(null); ToolContext context=new ToolContext(); context.put(WadlToolConstants.CFG_OUTPUTDIR,output.getCanonicalPath()); context.put(WadlToolConstants.CFG_WADLURL,getLocation("/wadl/resourceSameTargetNsSchemas.xml")); context.put(WadlToolConstants.CFG_COMPILE,"true"); container.setContext(context); container.execute(); List javaFiles=FileUtils.getFilesRecurse(output,".+\\." + "java" + "$"); assertEquals(4,javaFiles.size()); assertTrue(checkContains(javaFiles,"application.Resource.java")); assertTrue(checkContains(javaFiles,"com.example.test.ObjectFactory.java")); assertTrue(checkContains(javaFiles,"com.example.test.package-info.java")); assertTrue(checkContains(javaFiles,"com.example.test.TestCompositeObject.java")); List classFiles=FileUtils.getFilesRecurse(output,".+\\." + "class" + "$"); assertEquals(4,classFiles.size()); assertTrue(checkContains(classFiles,"application.Resource.class")); assertTrue(checkContains(classFiles,"com.example.test.ObjectFactory.class")); assertTrue(checkContains(classFiles,"com.example.test.package-info.class")); assertTrue(checkContains(classFiles,"com.example.test.TestCompositeObject.class")); assertNotNull(output.list()); } catch ( Exception e) { e.printStackTrace(); fail(); } }

Class: org.apache.cxf.tools.wadlto.jaxrs.WADLToJavaTest

UtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGenerateJAXBToString() throws Exception { try { String[] args=new String[]{"-d",output.getCanonicalPath(),"-p","custom.service","-async getName,delete","-compile","-xjc-episode " + output.getAbsolutePath() + "/test.episode","-xjc-XtoString",getLocation("/wadl/bookstore.xml")}; WADLToJava tool=new WADLToJava(args); tool.run(new ToolContext()); assertNotNull(output.list()); verifyFiles("java",true,false,"superbooks","custom.service"); verifyFiles("class",true,false,"superbooks","custom.service"); assertTrue(new File(output.getAbsolutePath() + "/test.episode").exists()); List> schemaClassFiles=getSchemaClassFiles(); assertEquals(4,schemaClassFiles.size()); for ( Class c : schemaClassFiles) { c.getMethod("toString"); } } catch ( Exception e) { e.printStackTrace(); fail(); } }

UtilityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGenerateJAXBToStringAndEqualsAndHashCode() throws Exception { try { String[] args=new String[]{"-d",output.getCanonicalPath(),"-p","custom.service","-async getName,delete","-compile","-xjc-XtoString","-xjc-Xequals","-xjc-XhashCode",getLocation("/wadl/bookstore.xml")}; WADLToJava tool=new WADLToJava(args); tool.run(new ToolContext()); assertNotNull(output.list()); verifyFiles("java",true,false,"superbooks","custom.service"); verifyFiles("class",true,false,"superbooks","custom.service"); List> schemaClassFiles=getSchemaClassFiles(); assertEquals(4,schemaClassFiles.size()); for ( Class c : schemaClassFiles) { c.getMethod("toString"); c.getMethod("hashCode"); c.getMethod("equals",Object.class); } } catch ( Exception e) { e.printStackTrace(); fail(); } }

Class: org.apache.cxf.tools.wsdlto.WSDLToJavaContainerTest

UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testValidateorSuppressWarningsIsOn() throws Exception { WSDLToJavaContainer container=new WSDLToJavaContainer("dummy",null); ToolContext context=new ToolContext(); context.put(ToolConstants.CFG_WSDLURL,getLocation("hello_world.wsdl")); container.setContext(context); try { container.execute(); } catch ( ToolException te) { assertEquals(getLogMessage("FOUND_NO_FRONTEND"),te.getMessage()); } catch ( Exception e) { fail("Should not throw any exception but ToolException."); } assertTrue(context.optionSet(ToolConstants.CFG_SUPPRESS_WARNINGS)); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testNoPlugin() throws Exception { WSDLToJavaContainer container=new WSDLToJavaContainer("dummy",null); ToolContext context=new ToolContext(); context.put(ToolConstants.CFG_WSDLURL,getLocation("hello_world.wsdl")); container.setContext(context); try { container.execute(); } catch ( ToolException te) { assertEquals(getLogMessage("FOUND_NO_FRONTEND"),te.getMessage()); } catch ( Exception e) { fail("Should not throw any exception but ToolException."); } }

Class: org.apache.cxf.tools.wsdlto.WSDLToJavaTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetFrontEndName() throws Exception { WSDLToJava w2j=new WSDLToJava(); assertEquals("jaxws",w2j.getFrontEndName(new String[]{"-frontend","jaxws"})); assertEquals("jaxws",w2j.getFrontEndName(new String[]{"-fe","jaxws"})); assertNull(w2j.getFrontEndName(new String[]{"-frontend"})); assertNull(w2j.getFrontEndName(new String[]{"-fe"})); assertNull(w2j.getFrontEndName(new String[]{"nothing"})); assertNull(w2j.getFrontEndName(null)); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetDataBindingName() throws Exception { WSDLToJava w2j=new WSDLToJava(); assertEquals("jaxb",w2j.getDataBindingName(new String[]{"-databinding","jaxb"})); assertEquals("jaxb",w2j.getDataBindingName(new String[]{"-db","jaxb"})); assertNull(w2j.getDataBindingName(new String[]{"-databinding"})); assertNull(w2j.getDataBindingName(new String[]{"-db"})); assertNull(w2j.getDataBindingName(new String[]{"nothing"})); assertNull(w2j.getDataBindingName(null)); assertNull(w2j.getDataBindingName(new String[]{"-frontend","jaxws"})); }

Class: org.apache.cxf.tools.wsdlto.core.PluginLoaderTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testLoadPlugins() throws Exception { PluginLoader loader=PluginLoader.getInstance(); assertEquals(4,loader.getPlugins().size()); Plugin plugin=getPlugin(loader,0); assertNotNull(plugin.getName()); Map frontends=loader.getFrontEnds(); assertNotNull(frontends); assertEquals(3,frontends.size()); FrontEnd frontend=getFrontEnd(frontends,0); assertEquals("jaxws",frontend.getName()); assertEquals("org.apache.cxf.tools.wsdlto.frontend.jaxws",frontend.getPackage()); assertEquals("JAXWSProfile",frontend.getProfile()); assertNotNull(frontend.getGenerators()); assertNotNull(frontend.getGenerators().getGenerator()); assertEquals("AntGenerator",getGenerator(frontend,0).getName()); assertEquals("JAXWSContainer",frontend.getContainer().getName()); assertEquals("jaxws-toolspec.xml",frontend.getContainer().getToolspec()); loader.getFrontEndProfile("jaxws"); Map databindings=loader.getDataBindings(); assertNotNull(databindings); assertEquals(6,databindings.size()); DataBinding databinding=databindings.get("jaxb"); assertNotNull(databinding); assertEquals("jaxb",databinding.getName()); assertEquals("org.apache.cxf.tools.wsdlto.databinding.jaxb",databinding.getPackage()); assertEquals("JAXBDataBinding",databinding.getProfile()); }

Class: org.apache.cxf.tools.wsdlto.core.WSDLDefinitionBuilderTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBuildSimpleWSDL() throws Exception { String qname="http://apache.org/hello_world_soap_http"; String wsdlUrl=getClass().getResource("hello_world.wsdl").toString(); WSDLDefinitionBuilder builder=new WSDLDefinitionBuilder(BusFactory.getDefaultBus()); Definition def=builder.build(wsdlUrl); assertNotNull(def); Map services=def.getServices(); assertNotNull(services); assertEquals(1,services.size()); Service service=(Service)services.get(new QName(qname,"SOAPService")); assertNotNull(service); Map ports=service.getPorts(); assertNotNull(ports); assertEquals(1,ports.size()); Port port=service.getPort("SoapPort"); assertNotNull(port); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBuildImportedWSDL() throws Exception { String wsdlUrl=getClass().getResource("hello_world_services.wsdl").toString(); WSDLDefinitionBuilder builder=new WSDLDefinitionBuilder(BusFactory.getDefaultBus()); Definition def=builder.build(wsdlUrl); assertNotNull(def); Map services=def.getServices(); assertNotNull(services); assertEquals(1,services.size()); String serviceQName="http://apache.org/hello_world/services"; Service service=(Service)services.get(new QName(serviceQName,"SOAPService")); assertNotNull(service); Map ports=service.getPorts(); assertNotNull(ports); assertEquals(1,ports.size()); Port port=service.getPort("SoapPort"); assertNotNull(port); Binding binding=port.getBinding(); assertNotNull(binding); QName bindingQName=new QName("http://apache.org/hello_world/bindings","SOAPBinding"); assertEquals(bindingQName,binding.getQName()); PortType portType=binding.getPortType(); assertNotNull(portType); QName portTypeQName=new QName("http://apache.org/hello_world","Greeter"); assertEquals(portTypeQName,portType.getQName()); Operation op1=portType.getOperation("sayHi","sayHiRequest","sayHiResponse"); assertNotNull(op1); QName messageQName=new QName("http://apache.org/hello_world/messages","sayHiRequest"); assertEquals(messageQName,op1.getInput().getMessage().getQName()); Part part=op1.getInput().getMessage().getPart("in"); assertNotNull(part); assertEquals(new QName("http://apache.org/hello_world/types","sayHi"),part.getElementName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBuildImportedWSDLSpacesInPath() throws Exception { WSDLDefinitionBuilder builder=new WSDLDefinitionBuilder(BusFactory.getDefaultBus()); String wsdlUrl=getClass().getResource("/folder with spaces/import_test.wsdl").toString(); Definition def=builder.build(wsdlUrl); assertNotNull(def); Map services=def.getServices(); assertNotNull(services); assertEquals(1,services.size()); String serviceQName="urn:S1importS2S3/resources/wsdl/S1importsS2S3Test1"; Service service=(Service)services.get(new QName(serviceQName,"S1importsS2S3TestService")); assertNotNull(service); Map ports=service.getPorts(); assertNotNull(ports); assertEquals(1,ports.size()); Port port=service.getPort("S1importsS2S3TestPort"); assertNotNull(port); }

Class: org.apache.cxf.tools.wsdlto.frontend.jaxws.CatalogTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCatalog() throws Exception { OASISCatalogManager catalogManager=new OASISCatalogManager(); URL jaxwscatalog=getClass().getResource("/META-INF/jax-ws-catalog.xml"); assertNotNull(jaxwscatalog); catalogManager.loadCatalog(jaxwscatalog); String xsd="http://www.w3.org/2005/08/addressing/ws-addr.xsd"; String resolvedSchemaLocation=catalogManager.resolveSystem(xsd); assertEquals("classpath:/schemas/wsdl/ws-addr.xsd",resolvedSchemaLocation); ExtendedURIResolver resolver=new ExtendedURIResolver(); InputSource in=resolver.resolve(resolvedSchemaLocation,null); assertTrue(in.getSystemId(),in.getSystemId().indexOf("core") != -1); assertTrue(in.getSystemId(),in.getSystemId().indexOf("/schemas/wsdl/ws-addr.xsd") != -1); }

Class: org.apache.cxf.tools.wsdlto.frontend.jaxws.JAXWSProfileTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testLoadPlugins(){ PluginLoader loader=PluginLoader.getInstance(); assertNotNull(loader); loader.loadPlugin("/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-plugin.xml"); assertEquals(3,loader.getPlugins().size()); Plugin plugin=null; for ( Plugin p : loader.getPlugins().values()) { if (p.getName().contains("jaxws")) { plugin=p; } } assertNotNull(plugin); assertEquals("tools-jaxws-frontend",plugin.getName()); assertEquals("2.0",plugin.getVersion()); assertEquals("apache cxf",plugin.getProvider()); Map frontends=loader.getFrontEnds(); assertNotNull(frontends); assertEquals(3,frontends.size()); FrontEnd frontend=getFrontEnd(frontends,0); assertEquals("jaxws",frontend.getName()); assertEquals("org.apache.cxf.tools.wsdlto.frontend.jaxws",frontend.getPackage()); assertEquals("JAXWSProfile",frontend.getProfile()); assertNotNull(frontend.getGenerators()); assertNotNull(frontend.getGenerators().getGenerator()); assertEquals(2,frontend.getGenerators().getGenerator().size()); assertEquals("AntGenerator",getGenerator(frontend,0).getName()); assertEquals("ImplGenerator",getGenerator(frontend,1).getName()); FrontEndProfile profile=loader.getFrontEndProfile("jaxws"); assertNotNull(profile); List generators=profile.getGenerators(); assertNotNull(generators); assertEquals(2,generators.size()); assertTrue(generators.get(0) instanceof AntGenerator); assertTrue(generators.get(1) instanceof ImplGenerator); Processor processor=profile.getProcessor(); assertNotNull(processor); assertTrue(processor instanceof WSDLToJavaProcessor); AbstractWSDLBuilder builder=profile.getWSDLBuilder(); assertNotNull(builder); assertTrue(builder instanceof JAXWSDefinitionBuilder); Class container=profile.getContainerClass(); assertEquals(container,JAXWSContainer.class); assertEquals("/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml",profile.getToolspec()); }

Class: org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.ParameterProcessorTest

InternalCallVerifier EqualityVerifier 
@Test public void testAddParameter() throws Exception { ParameterProcessor processor=new ParameterProcessor(new ToolContext()); JavaMethod method=new JavaMethod(); JavaParameter p1=new JavaParameter("request",String.class.getName(),null); p1.setStyle(JavaType.Style.IN); processor.addParameter(null,method,p1); JavaParameter p2=new JavaParameter("request",String.class.getName(),null); p2.setStyle(JavaType.Style.OUT); processor.addParameter(null,method,p2); assertEquals(1,method.getParameters().size()); assertEquals(JavaType.Style.INOUT,method.getParameters().get(0).getStyle()); }

Class: org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.ProcessorUtilTest

BranchVerifier EqualityVerifier 
@Test public void testGetAbsolutePath() throws Exception { assertEquals("http://cxf.org",ProcessorUtil.getAbsolutePath("http://cxf.org")); if (isWindows()) { assertEquals("c:/org/cxf",ProcessorUtil.getAbsolutePath("c:\\org\\cxf")); assertEquals("c:/org/cxf",ProcessorUtil.getAbsolutePath("c:/org/cxf")); } }

Class: org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.annotator.WebMethodAnnotatorTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAddWebMethodAnnotation() throws Exception { JavaMethod method=new JavaMethod(); method.setName("echoFoo"); method.setOperationName("echoFoo"); method.annotate(new WebMethodAnnotator()); Map annotations=method.getAnnotationMap(); assertNotNull(annotations); assertEquals(1,annotations.size()); assertEquals("WebMethod",annotations.keySet().iterator().next()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAddWebResultAnnotation() throws Exception { JavaMethod method=new JavaMethod(); method.annotate(new WebResultAnnotator()); Map annotations=method.getAnnotationMap(); assertNotNull(annotations); assertEquals(1,annotations.size()); assertEquals("WebResult",annotations.keySet().iterator().next()); JAnnotation resultAnnotation=annotations.get("WebResult"); assertEquals("@WebResult(name = \"return\")",resultAnnotation.toString()); List elements=resultAnnotation.getElements(); assertNotNull(elements); assertEquals(1,elements.size()); assertEquals("name",elements.get(0).getName()); assertEquals("return",elements.get(0).getValue()); }

Class: org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.annotator.WebParamAnnotatorTest

InternalCallVerifier EqualityVerifier 
@Test public void testAnnotateRPC() throws Exception { init(method,parameter,SOAPBinding.Style.RPC,true); parameter.annotate(new WebParamAnnotator()); JAnnotation annotation=parameter.getAnnotation("WebParam"); assertEquals(2,annotation.getElements().size()); assertEquals("@WebParam(partName = \"y\", name = \"y\")",annotation.toString()); }

InternalCallVerifier EqualityVerifier 
@Test public void testAnnotateDOCBare() throws Exception { init(method,parameter,SOAPBinding.Style.DOCUMENT,false); parameter.annotate(new WebParamAnnotator()); JAnnotation annotation=parameter.getAnnotation("WebParam"); assertEquals("@WebParam(partName = \"y\", name = \"x\", " + "targetNamespace = \"http://apache.org/cxf\")",annotation.toString()); List elements=annotation.getElements(); assertEquals(3,elements.size()); }

InternalCallVerifier EqualityVerifier 
@Test public void testAnnotateDOCWrapped() throws Exception { init(method,parameter,SOAPBinding.Style.DOCUMENT,true); parameter.annotate(new WebParamAnnotator()); JAnnotation annotation=parameter.getAnnotation("WebParam"); assertEquals("@WebParam(name = \"x\", targetNamespace = \"http://apache.org/cxf\")",annotation.toString()); List elements=annotation.getElements(); assertEquals(2,elements.size()); assertEquals("http://apache.org/cxf",elements.get(1).getValue()); assertEquals("x",elements.get(0).getValue()); }

Class: org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.annotator.XmlSeeAlsoAnnotatorTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testAddXmlSeeAlsoAnnotation() throws Exception { JavaInterface intf=new JavaInterface(); assertFalse(intf.getImports().hasNext()); ClassCollector collector=new ClassCollector(); collector.getTypesPackages().add(ObjectFactory.class.getPackage().getName()); intf.annotate(new XmlSeeAlsoAnnotator(collector)); Iterator iter=intf.getImports(); assertEquals("javax.xml.bind.annotation.XmlSeeAlso",iter.next()); assertEquals("@XmlSeeAlso({" + ObjectFactory.class.getName() + ".class})",intf.getAnnotations().iterator().next().toString()); }

Class: org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.mapper.InterfaceMapperTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testMap() throws Exception { InterfaceInfo interfaceInfo=new InterfaceInfo(new ServiceInfo(),new QName("http://apache.org/hello_world_soap_http","interfaceTest")); ToolContext context=new ToolContext(); context.put(ToolConstants.CFG_WSDLURL,"http://localhost/?wsdl"); JavaInterface intf=new InterfaceMapper(context).map(interfaceInfo); assertNotNull(intf); assertEquals("interfaceTest",intf.getWebServiceName()); assertEquals("InterfaceTest",intf.getName()); assertEquals("http://apache.org/hello_world_soap_http",intf.getNamespace()); assertEquals("org.apache.hello_world_soap_http",intf.getPackageName()); assertEquals("http://localhost/?wsdl",intf.getLocation()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testMapWithUniqueWsdlLoc() throws Exception { InterfaceInfo interfaceInfo=new InterfaceInfo(new ServiceInfo(),new QName("http://apache.org/hello_world_soap_http","interfaceTest")); ToolContext context=new ToolContext(); context.put(ToolConstants.CFG_WSDLURL,"http://localhost/?wsdl"); context.put(ToolConstants.CFG_WSDLLOCATION,"/foo/blah.wsdl"); JavaInterface intf=new InterfaceMapper(context).map(interfaceInfo); assertNotNull(intf); assertEquals("interfaceTest",intf.getWebServiceName()); assertEquals("InterfaceTest",intf.getName()); assertEquals("http://apache.org/hello_world_soap_http",intf.getNamespace()); assertEquals("org.apache.hello_world_soap_http",intf.getPackageName()); assertEquals("/foo/blah.wsdl",intf.getLocation()); }

Class: org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.mapper.MethodMapperTest

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testMap() throws Exception { JavaMethod method=new MethodMapper().map(getOperation()); assertNotNull(method); assertEquals(javax.jws.soap.SOAPBinding.Style.DOCUMENT,method.getSoapStyle()); assertEquals("operationTest",method.getName()); assertEquals("OperationTest",method.getOperationName()); assertEquals(OperationType.REQUEST_RESPONSE,method.getStyle()); assertFalse(method.isWrapperStyle()); assertFalse(method.isOneWay()); }

Class: org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilderTest

APIUtilityVerifier IterativeVerifier InternalCallVerifier EqualityVerifier 
@Test public void testCustomization(){ env.put(ToolConstants.CFG_WSDLURL,getClass().getResource("resources/hello_world.wsdl").toString()); env.put(ToolConstants.CFG_BINDING,getClass().getResource("resources/binding2.xml").toString()); JAXWSDefinitionBuilder builder=new JAXWSDefinitionBuilder(); builder.setContext(env); builder.setBus(BusFactory.getDefaultBus()); builder.build(); builder.customize(); Definition customizedDef=builder.getWSDLModel(); List defExtensionList=customizedDef.getExtensibilityElements(); Iterator ite=defExtensionList.iterator(); while (ite.hasNext()) { ExtensibilityElement extElement=(ExtensibilityElement)ite.next(); JAXWSBinding binding=(JAXWSBinding)extElement; assertEquals("Customized package name does not been parsered","com.foo",binding.getPackage()); assertEquals("Customized enableAsync does not parsered",true,binding.isEnableAsyncMapping()); } PortType portType=customizedDef.getPortType(new QName("http://apache.org/hello_world_soap_http","Greeter")); List portTypeList=portType.getExtensibilityElements(); JAXWSBinding binding=(JAXWSBinding)portTypeList.get(0); assertEquals("Customized enable EnableWrapperStyle name does not been parsered",true,binding.isEnableWrapperStyle()); List opList=portType.getOperations(); Operation operation=(Operation)opList.get(0); List extList=operation.getExtensibilityElements(); binding=(JAXWSBinding)extList.get(0); assertEquals("Customized method name does not parsered","echoMeOneWay",binding.getMethodName()); assertEquals("Customized parameter element name does not parsered","number1",binding.getJaxwsParas().get(0).getElementName().getLocalPart()); assertEquals("Customized parameter message name does not parsered","greetMeOneWayRequest",binding.getJaxwsParas().get(0).getMessageName()); assertEquals("customized parameter name does not parsered","num1",binding.getJaxwsParas().get(0).getName()); }

APIUtilityVerifier IterativeVerifier InternalCallVerifier EqualityVerifier 
@Test public void testCustomizationWithDifferentNS(){ env.put(ToolConstants.CFG_WSDLURL,getClass().getResource("resources/hello_world.wsdl").toString()); env.put(ToolConstants.CFG_BINDING,getClass().getResource("resources/binding3.xml").toString()); JAXWSDefinitionBuilder builder=new JAXWSDefinitionBuilder(); builder.setContext(env); builder.setBus(BusFactory.getDefaultBus()); builder.build(); builder.customize(); Definition customizedDef=builder.getWSDLModel(); List defExtensionList=customizedDef.getExtensibilityElements(); Iterator ite=defExtensionList.iterator(); while (ite.hasNext()) { ExtensibilityElement extElement=(ExtensibilityElement)ite.next(); JAXWSBinding binding=(JAXWSBinding)extElement; assertEquals("Customized package name does not been parsered","com.foo",binding.getPackage()); assertEquals("Customized enableAsync does not parsered",true,binding.isEnableAsyncMapping()); } PortType portType=customizedDef.getPortType(new QName("http://apache.org/hello_world_soap_http","Greeter")); List portTypeList=portType.getExtensibilityElements(); JAXWSBinding binding=(JAXWSBinding)portTypeList.get(0); assertEquals("Customized enable EnableWrapperStyle name does not been parsered",true,binding.isEnableWrapperStyle()); List opList=portType.getOperations(); Operation operation=(Operation)opList.get(0); List extList=operation.getExtensibilityElements(); binding=(JAXWSBinding)extList.get(0); assertEquals("Customized method name does not parsered","echoMeOneWay",binding.getMethodName()); assertEquals("Customized parameter element name does not parsered","number1",binding.getJaxwsParas().get(0).getElementName().getLocalPart()); assertEquals("Customized parameter message name does not parsered","greetMeOneWayRequest",binding.getJaxwsParas().get(0).getMessageName()); assertEquals("customized parameter name does not parsered","num1",binding.getJaxwsParas().get(0).getName()); }

Class: org.apache.cxf.tools.wsdlto.javascript.WSDLToJavaScriptTest

APIUtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testGeneration() throws Exception { JavaScriptContainer container=new JavaScriptContainer(null); ToolContext context=new ToolContext(); context.put(ToolConstants.CFG_WSDLURL,getLocation("hello_world.wsdl")); context.put(ToolConstants.CFG_OUTPUTDIR,output.toString()); String[] prefixes=new String[1]; prefixes[0]="http://apache.org/hello_world_soap_http=murble"; context.put(ToolConstants.CFG_JSPACKAGEPREFIX,prefixes); container.setContext(context); container.execute(); Path path=FileSystems.getDefault().getPath(output.getPath(),"SOAPService_Test1.js"); assertTrue(Files.isReadable(path)); String javascript=new String(Files.readAllBytes(path),StandardCharsets.UTF_8); assertTrue(javascript.contains("xmlns:murble='http://apache.org/hello_world_soap_http'")); assertEquals("Number of '{' does not match number of '}' in generated JavaScript.",countChar(javascript,'{'),countChar(javascript,'}')); }

APIUtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testCXF3891() throws Exception { JavaScriptContainer container=new JavaScriptContainer(null); ToolContext context=new ToolContext(); context.put(ToolConstants.CFG_WSDLURL,getLocation("hello_world_ref.wsdl")); context.put(ToolConstants.CFG_OUTPUTDIR,output.toString()); String[] prefixes=new String[1]; prefixes[0]="http://apache.org/hello_world_soap_http=murble"; context.put(ToolConstants.CFG_JSPACKAGEPREFIX,prefixes); container.setContext(context); container.execute(); Path path=FileSystems.getDefault().getPath(output.getPath(),"SOAPService.js"); assertTrue(Files.isReadable(path)); String javascript=new String(Files.readAllBytes(path),StandardCharsets.UTF_8); assertTrue(javascript.contains("xmlns:murble='http://apache.org/hello_world_soap_http'")); assertEquals("Number of '{' does not match number of '}' in generated JavaScript.",countChar(javascript,'{'),countChar(javascript,'}')); }

Class: org.apache.cxf.tools.wsdlto.jaxws.CodeGenBugTest

APIUtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDefaultLoadNSMappingOFF() throws Exception { String[] args=new String[]{"-dns","false","-d",output.getCanonicalPath(),"-noAddressBinding",getLocation("/wsdl2java_wsdl/basic_callback.wsdl")}; WSDLToJava.main(args); assertNotNull(output); File org=new File(output,"org"); assertTrue(org.exists()); File w3=new File(org,"w3"); assertTrue(w3.exists()); File p2005=new File(w3,"_2005"); assertTrue(p2005.exists()); File p08=new File(p2005,"_08"); assertTrue(p08.exists()); File address=new File(p08,"addressing"); assertTrue(address.exists()); File[] files=address.listFiles(); assertEquals(11,files.length); }

APIUtilityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCXF5280() throws Exception { env.put(ToolConstants.CFG_ALL,"all"); env.put(ToolConstants.CFG_COMPILE,"compile"); env.put(ToolConstants.CFG_OUTPUTDIR,output.getCanonicalPath()); env.put(ToolConstants.CFG_CLASSDIR,output.getCanonicalPath() + "/classes"); env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/cxf5280/hello_world.wsdl")); processor.setContext(env); processor.execute(); Class pcls=classLoader.loadClass("org.apache.cxf.w2j.hello_world_soap_http.Greeter"); Class acls=classLoader.loadClass("org.apache.cxf.w2j.hello_world_soap_http.types.GreetMe"); Method m=pcls.getMethod("greetMe",new Class[]{acls}); Action actionAnn=AnnotationUtil.getPrivMethodAnnotation(m,Action.class); assertNotNull(actionAnn); assertEquals("http://cxf.apache.org/w2j/hello_world_soap_http/greetMe",actionAnn.input()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testCXF2935() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/cxf2935/webservice.wsdl")); env.put(ToolConstants.CFG_ALLOW_ELEMENT_REFS,"true"); processor.setContext(env); processor.execute(); Class clz=classLoader.loadClass("org.apache.cxf.WebParamWebService"); WebParam webParam=AnnotationUtil.getWebParam(clz.getMethods()[0],"Name"); assertEquals("helloString/Name",webParam.targetNamespace()); }

EqualityVerifier 
@Test public void testWrapperStyleNameCollision() throws Exception { try { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/cxf918/bug.wsdl")); processor.setContext(env); processor.execute(); } catch ( Exception e) { String ns1="http://bugs.cxf/services/bug1"; String ns2="http://www.w3.org/2001/XMLSchema"; QName elementName=new QName(ns1,"theSameNameFieldDifferentDataType"); QName stringName=new QName(ns2,"string"); QName intName=new QName(ns2,"int"); Message msg=new Message("WRAPPER_STYLE_NAME_COLLISION",UniqueBodyValidator.LOG,elementName,stringName,intName); assertEquals(msg.toString().trim(),e.getMessage().trim()); } }

APIUtilityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testTwoJaxwsBindingFile() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/hello_world.wsdl")); env.put(ToolConstants.CFG_BINDING,new String[]{getLocation("/wsdl2java_wsdl/cxf1152/jaxws1.xml"),getLocation("/wsdl2java_wsdl/cxf1152/jaxws2.xml")}); processor.setContext(env); processor.execute(); File file=new File(output,"org/mypkg"); assertEquals(25,file.listFiles().length); Class clz=classLoader.loadClass("org.mypkg.MyService"); assertNotNull("Customized service class is not found",clz); clz=classLoader.loadClass("org.mypkg.MyGreeter"); assertNotNull("Customized SEI class is not found",clz); Method customizedMethod=clz.getMethod("myGreetMe",new Class[]{String.class}); assertNotNull("Customized method 'myGreetMe' in MyGreeter.class is not found",customizedMethod); }

APIUtilityVerifier EqualityVerifier 
@Test public void testCXF2944() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/cxf2944/cxf2944.wsdl")); env.put(ToolConstants.CFG_ALLOW_ELEMENT_REFS,"true"); processor.setContext(env); processor.execute(); Class clz=classLoader.loadClass("org.apache.cxf.tools.fortest.cxf2944.WebResultService"); WebResult webResult=AnnotationUtil.getWebResult(clz.getMethods()[0]); assertEquals("hello/name",webResult.targetNamespace()); assertEquals("name",webResult.name()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testCXF964() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/cxf964/hello_world_fault.wsdl")); processor.setContext(env); processor.execute(); Class clz=classLoader.loadClass("org.apache.intfault.BadRecordLitFault"); WebFault webFault=AnnotationUtil.getPrivClassAnnotation(clz,WebFault.class); assertEquals("int",webFault.name()); }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testClientServer() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/bug765/hello_world_ports.wsdl")); env.remove(ToolConstants.CFG_COMPILE); env.remove(ToolConstants.CFG_IMPL); env.put(ToolConstants.CFG_GEN_SERVER,ToolConstants.CFG_GEN_SERVER); env.put(ToolConstants.CFG_GEN_CLIENT,ToolConstants.CFG_GEN_CLIENT); processor.setContext(env); processor.execute(); File file=new File(output,"org/apache/cxf/w2j/hello_world_soap_http"); assertEquals(Arrays.asList(file.list()).toString(),4,file.list().length); file=new File(output,"org/apache/cxf/w2j/hello_world_soap_http/DocLitBare_DocLitBarePort_Client.java"); assertTrue("DocLitBare_DocLitBarePort_Client is not found",file.exists()); file=new File(output,"org/apache/cxf/w2j/hello_world_soap_http/DocLitBare_DocLitBarePort_Server.java"); assertTrue("DocLitBare_DocLitBarePort_Server is not found",file.exists()); file=new File(output,"org/apache/cxf/w2j/hello_world_soap_http/Greeter_GreeterPort_Client.java"); assertTrue("Greeter_GreeterPort_Client is not found",file.exists()); file=new File(output,"org/apache/cxf/w2j/hello_world_soap_http/Greeter_GreeterPort_Server.java"); assertTrue("Greeter_GreeterPort_Server is not found",file.exists()); }

APIUtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDefaultLoadNSMappingON() throws Exception { String[] args=new String[]{"-d",output.getCanonicalPath(),"-noAddressBinding",getLocation("/wsdl2java_wsdl/basic_callback.wsdl")}; WSDLToJava.main(args); assertNotNull(output); File org=new File(output,"org"); assertTrue(org.exists()); File apache=new File(org,"apache"); assertTrue(apache.exists()); File cxf=new File(apache,"cxf"); assertTrue(cxf.exists()); File ws=new File(cxf,"ws"); assertTrue(ws.exists()); File address=new File(ws,"addressing"); assertTrue(address.exists()); File[] files=address.listFiles(); assertEquals(11,files.length); }

EqualityVerifier 
@Test public void testCXF627() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/bug627/hello_world.wsdl")); env.put(ToolConstants.CFG_BINDING,getLocation("/wsdl2java_wsdl/bug627/async_binding.xml")); processor.setContext(env); try { processor.execute(); } catch ( Exception ex) { } Class clz=classLoader.loadClass("org.apache.cxf.w2j.hello_world_soap_http.Greeter"); assertEquals(3,clz.getDeclaredMethods().length); }

APIUtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testNamespacePackageMapping3() throws Exception { env.put(ToolConstants.CFG_PACKAGENAME,"org.cxf"); env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/hello_world.wsdl")); processor.setContext(env); processor.execute(); File org=new File(output,"org"); assertTrue(org.exists()); File cxf=new File(org,"cxf"); File[] files=cxf.listFiles(); assertEquals(25,files.length); Class clz=classLoader.loadClass("org.cxf.Greeter"); assertTrue("Generate " + clz.getName() + "error",clz.isInterface()); }

APIUtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testNamespacePackageMapping1() throws Exception { env.addNamespacePackageMap("http://cxf.apache.org/w2j/hello_world_soap_http/types","org.apache.types"); env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/hello_world.wsdl")); processor.setContext(env); processor.execute(); File org=new File(output,"org"); assertTrue(org.exists()); File apache=new File(org,"apache"); assertTrue(apache.exists()); File types=new File(apache,"types"); assertTrue(types.exists()); File[] files=apache.listFiles(); assertEquals(2,files.length); files=types.listFiles(); assertEquals(17,files.length); Class clz=classLoader.loadClass("org.apache.types.GreetMe"); assertNotNull(clz); }

APIUtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBindingXPath() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/hello_world.wsdl")); env.put(ToolConstants.CFG_BINDING,getLocation("/wsdl2java_wsdl/cxf1106/binding.xml")); processor.setContext(env); processor.execute(); Class clz=classLoader.loadClass("org.apache.cxf.w2j.hello_world_soap_http.Greeter"); assertNotNull("Failed to generate SEI class",clz); Method[] methods=clz.getMethods(); assertEquals("jaxws binding file parse error, number of generated method is not expected",14,methods.length); boolean existSayHiAsyn=false; for ( Method m : methods) { if (m.getName().equals("sayHiAsyn")) { existSayHiAsyn=true; } } assertFalse("sayHiAsyn method should not be generated",existSayHiAsyn); }

APIUtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDefaultNSWithPkg() throws Exception { String[] args=new String[]{"-d",output.getCanonicalPath(),"-p","org.cxf","-noAddressBinding",getLocation("/wsdl2java_wsdl/basic_callback.wsdl")}; WSDLToJava.main(args); assertNotNull(output); File org=new File(output,"org"); assertTrue(org.exists()); File apache=new File(org,"apache"); assertTrue(apache.exists()); File cxf=new File(apache,"cxf"); assertTrue(cxf.exists()); File ws=new File(cxf,"ws"); assertTrue(ws.exists()); File address=new File(ws,"addressing"); assertTrue(address.exists()); File[] files=address.listFiles(); assertEquals(11,files.length); cxf=new File(output,"org/cxf"); assertTrue(cxf.exists()); files=cxf.listFiles(); assertEquals(5,files.length); }

APIUtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testServiceNS() throws Exception { env.put(ToolConstants.CFG_ALL,ToolConstants.CFG_ALL); env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/bug321/hello_world_different_ns_service.wsdl")); processor.setContext(env); processor.execute(); Class clz=classLoader.loadClass("org.apache.cxf.w2j.hello_world_soap_http.service.SOAPServiceTest1"); WebServiceClient webServiceClient=AnnotationUtil.getPrivClassAnnotation(clz,WebServiceClient.class); assertEquals("http://cxf.apache.org/w2j/hello_world_soap_http/service",webServiceClient.targetNamespace()); File file=new File(output,"org/apache/cxf/w2j/hello_world_soap_http/Greeter_SoapPortTest1_Client.java"); FileInputStream fin=new FileInputStream(file); byte[] buffer=new byte[30000]; int index=-1; int size=fin.read(buffer); ByteArrayOutputStream bout=new ByteArrayOutputStream(); while (size != -1) { bout.write(buffer,0,size); index=bout.toString().indexOf("new QName(\"http://cxf.apache.org/w2j/hello_world_soap_http/service\"," + " \"SOAPService_Test1\")"); if (index > 0) { break; } size=fin.read(buffer); } fin.close(); assertTrue("Service QName in client is not correct",index > -1); }

APIUtilityVerifier EqualityVerifier 
@Test public void testCXF3290() throws Exception { env.put(ToolConstants.CFG_COMPILE,"compile"); env.put(ToolConstants.CFG_OUTPUTDIR,output.getCanonicalPath()); env.put(ToolConstants.CFG_CLASSDIR,output.getCanonicalPath() + "/classes"); env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/cxf-3290/bug.wsdl")); processor.setContext(env); processor.execute(); Class cls=classLoader.loadClass("org.apache.cxf.bugs3290.services.bug1.MyBugService"); Method m=cls.getMethod("getMyBug1"); assertEquals(classLoader.loadClass("org.apache.cxf.bugs3290.services.bug2.MyBugService"),m.getReturnType()); }

EqualityVerifier 
@Test public void testCXF1620() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/jaxb_custom_extensors.wsdl")); env.put(ToolConstants.CFG_BINDING,getLocation("/wsdl2java_wsdl/jaxb_custom_extensors.xjb")); processor.setContext(env); processor.execute(); Class clz=classLoader.loadClass("org.apache.cxf.w2j.jaxb_custom_ext.types.Foo"); assertEquals(3,clz.getDeclaredFields().length); clz=classLoader.loadClass("org.apache.cxf.w2j.jaxb_custom_ext.types.Foo2"); assertEquals(1,clz.getDeclaredFields().length); }

EqualityVerifier 
@Test public void testServer() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/InvoiceServer.wsdl")); env.put(ToolConstants.CFG_BINDING,new String[]{getLocation("/wsdl2java_wsdl/cxf1141/jaxws.xml"),getLocation("/wsdl2java_wsdl/cxf1141/jaxb.xml")}); processor.setContext(env); processor.execute(); File file=new File(output,"org/mytest"); assertEquals(13,file.list().length); }

APIUtilityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testLogicalOnlyWSDL() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/cxf-1678/hello_world_logical_only.wsdl")); env.remove(ToolConstants.CFG_VALIDATE_WSDL); processor.setContext(env); processor.execute(); assertNotNull("Trouble processing logical only wsdl",output); Class clz=classLoader.loadClass("org.apache.cxf.cxf1678.hello_world_soap_http.GreeterImpl"); WebService webServiceAnn=AnnotationUtil.getPrivClassAnnotation(clz,WebService.class); assertEquals("org.apache.cxf.cxf1678.hello_world_soap_http.Greeter",webServiceAnn.endpointInterface()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testCXF1048() throws Exception { env.put(ToolConstants.CFG_COMPILE,"compile"); env.put(ToolConstants.CFG_IMPL,ToolConstants.CFG_IMPL); env.put(ToolConstants.CFG_OUTPUTDIR,output.getCanonicalPath()); env.put(ToolConstants.CFG_CLASSDIR,output.getCanonicalPath() + "/classes"); env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/cxf1048/test.wsdl")); processor.setContext(env); processor.execute(); Class clz=classLoader.loadClass("org.apache.hello_world_soap_http.PingSoapPortImpl"); WebService webServiceAnn=AnnotationUtil.getPrivClassAnnotation(clz,WebService.class); assertEquals("org.apache.hello_world_soap_http.Ping",webServiceAnn.endpointInterface()); assertEquals("GreeterSOAPService",webServiceAnn.serviceName()); assertEquals("PingSoapPort",webServiceAnn.portName()); }

Class: org.apache.cxf.tools.wsdlto.jaxws.CodeGenOptionTest

BooleanVerifier EqualityVerifier HybridVerifier 
/** * Tests that, when 'mark-generated' option is set, @Generated annotations are inserted in all generated * java classes. */ @Test public void testMarkGeneratedOption() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/hello_world.wsdl")); env.put(ToolConstants.CFG_MARK_GENERATED,"true"); env.put(ToolConstants.CFG_COMPILE,null); env.put(ToolConstants.CFG_CLASSDIR,null); processor.setContext(env); processor.execute(); File dir=new File(output,"org"); assertTrue("org directory is not found",dir.exists()); dir=new File(dir,"apache"); assertTrue("apache directory is not found",dir.exists()); dir=new File(dir,"cxf"); assertTrue("cxf directory is not found",dir.exists()); dir=new File(dir,"w2j"); assertTrue("w2j directory is not found",dir.exists()); dir=new File(dir,"hello_world_soap_http"); assertTrue("hello_world_soap_http directory is not found",dir.exists()); File types=new File(dir,"types"); assertTrue("types directory is not found",dir.exists()); String str=IOUtils.readStringFromStream(new FileInputStream(new File(dir,"Greeter.java"))); assertEquals(7,countGeneratedAnnotations(str)); str=IOUtils.readStringFromStream(new FileInputStream(new File(types,"SayHi.java"))); assertEquals(1,countGeneratedAnnotations(str)); str=IOUtils.readStringFromStream(new FileInputStream(new File(types,"SayHiResponse.java"))); assertEquals(4,countGeneratedAnnotations(str)); }

BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testHelloWorldExternalBindingFile() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/hello_world_jaxws_base.wsdl")); env.put(ToolConstants.CFG_BINDING,getLocation("/wsdl2java_wsdl/hello_world_jaxws_binding.wsdl")); processor.setContext(env); processor.execute(); assertNotNull(output); File org=new File(output,"org"); assertTrue(org.exists()); File apache=new File(org,"apache"); assertTrue(apache.exists()); Class clz=classLoader.loadClass("org.apache.cxf.w2j.hello_world_async_soap_http.GreeterAsync"); assertEquals(3,clz.getMethods().length); }

APIUtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testEncoding() throws Exception { try { CodeWriter.class.getDeclaredField("encoding"); } catch ( Throwable t) { return; } env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/hello_world_encoding.wsdl")); env.put(ToolConstants.CFG_WSDLLOCATION,"/wsdl2java_wsdl/hello_world_encoding.wsdl"); env.put(ToolConstants.CFG_ENCODING,"Cp1251"); processor.setContext(env); processor.execute(); File dir=new File(output,"org"); assertTrue("org directory is not found",dir.exists()); dir=new File(dir,"apache"); assertTrue("apache directory is not found",dir.exists()); dir=new File(dir,"cxf"); assertTrue("cxf directory is not found",dir.exists()); dir=new File(dir,"w2j"); assertTrue("w2j directory is not found",dir.exists()); dir=new File(dir,"hello_world_soap_http"); assertTrue("hello_world_soap_http directory is not found",dir.exists()); String str=IOUtils.readStringFromStream(new FileInputStream(new File(dir,"SOAPService.java"))); assertTrue(str,str.contains("getResource")); Class clz=classLoader.loadClass("org.apache.cxf.w2j.hello_world_soap_http.Greeter"); for ( Method m : clz.getMethods()) { String s=m.getName(); assertEquals(1039,s.charAt(2)); } }

EqualityVerifier 
@Test public void testGenFault() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/hello_world.wsdl")); env.remove(ToolConstants.CFG_COMPILE); env.remove(ToolConstants.CFG_IMPL); env.put(ToolConstants.CFG_GEN_FAULT,ToolConstants.CFG_GEN_FAULT); processor.setContext(env); processor.execute(); File file=new File(output,"org/apache/cxf/w2j/hello_world_soap_http"); assertEquals(2,file.list().length); }

Class: org.apache.cxf.tools.wsdlto.jaxws.CodeGenTest

APIUtilityVerifier EqualityVerifier 
@Test public void testWebFaultAnnotation() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/jms_test_rpc_fault.wsdl")); env.put(ToolConstants.CFG_SERVICENAME,"HelloWorldService"); env.remove(ToolConstants.CFG_VALIDATE_WSDL); processor.setContext(env); processor.execute(); Class cls=classLoader.loadClass("org.apache.cxf.w2j.hello_world_jms.BadRecordLitFault"); WebFault webFault=AnnotationUtil.getPrivClassAnnotation(cls,WebFault.class); assertEquals("http://www.w3.org/2001/XMLSchema",webFault.targetNamespace()); }

APIUtilityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSWAMime() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/swa-mime.wsdl")); env.put(ToolConstants.CFG_BINDING,getLocation("/wsdl2java_wsdl/swa-mime-binding.xml")); env.remove(ToolConstants.CFG_VALIDATE_WSDL); processor.setContext(env); processor.execute(); Class clz=classLoader.loadClass("org.apache.cxf.swa.SwAServiceInterface"); Method method1=clz.getMethod("echoData",new Class[]{javax.xml.ws.Holder.class,javax.xml.ws.Holder.class}); assertNotNull("method echoData can not be found",method1); Type[] types=method1.getGenericParameterTypes(); ParameterizedType paraType=(ParameterizedType)types[1]; Class typeClass=(Class)paraType.getActualTypeArguments()[0]; assertEquals("javax.activation.DataHandler",typeClass.getName()); }

APIUtilityVerifier IterativeVerifier BranchVerifier UtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testHeaderFromAnotherMessage4() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/pizza_wrapped.wsdl")); env.put(ToolConstants.CFG_EXTRA_SOAPHEADER,"TRUE"); processor.setContext(env); processor.execute(); assertNotNull(output); Class clz=classLoader.loadClass("org.apache.cxf.pizza_wrapped.Pizza"); Method meths[]=clz.getMethods(); for ( Method m : meths) { if ("orderPizza".equals(m.getName())) { Annotation annotations[][]=m.getParameterAnnotations(); assertEquals(2,annotations.length); for (int i=0; i < 2; i++) { assertTrue(annotations[i][0] instanceof WebParam); WebParam parm=(WebParam)annotations[i][0]; if ("Toppings".equals(parm.name())) { assertEquals("http://cxf.apache.org/pizza_wrapped/types",parm.targetNamespace()); assertTrue(!parm.header()); } else if ("CallerIDHeader".equals(parm.name())) { assertEquals("http://cxf.apache.org/pizza_wrapped/types",parm.targetNamespace()); assertTrue(parm.header()); } else { fail("No WebParam found!"); } } } } }

APIUtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testFaultSerialVersionUIDNONEFQCN() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/hello_world.wsdl")); env.put(ToolConstants.CFG_FAULT_SERIAL_VERSION_UID,"FQCN"); processor.setContext(env); processor.execute(); File faultFile=new File(output,"org/apache/cxf/w2j/hello_world_soap_http/NoSuchCodeLitFault.java"); assertTrue(faultFile.exists()); faultFile=new File(output,"org/apache/cxf/w2j/hello_world_soap_http/BadRecordLitFault.java"); assertTrue(faultFile.exists()); Class fault=classLoader.loadClass("org.apache.cxf.w2j.hello_world_soap_http.NoSuchCodeLitFault"); Field serialVersionUID=fault.getDeclaredField("serialVersionUID"); assertNotNull(serialVersionUID); assertEquals(fault.getName().hashCode(),ObjectStreamClass.lookup(fault).getSerialVersionUID()); fault=classLoader.loadClass("org.apache.cxf.w2j.hello_world_soap_http.BadRecordLitFault"); assertEquals(fault.getName().hashCode(),ObjectStreamClass.lookup(fault).getSerialVersionUID()); }

APIUtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testFaultSerialVersionUIDNumber() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/hello_world.wsdl")); env.put(ToolConstants.CFG_FAULT_SERIAL_VERSION_UID,"123456789"); processor.setContext(env); processor.execute(); File faultFile=new File(output,"org/apache/cxf/w2j/hello_world_soap_http/NoSuchCodeLitFault.java"); assertTrue(faultFile.exists()); faultFile=new File(output,"org/apache/cxf/w2j/hello_world_soap_http/BadRecordLitFault.java"); assertTrue(faultFile.exists()); Class fault=classLoader.loadClass("org.apache.cxf.w2j.hello_world_soap_http.NoSuchCodeLitFault"); Field serialVersionUID=fault.getDeclaredField("serialVersionUID"); assertNotNull(serialVersionUID); Long l=(Long)serialVersionUID.get(null); assertEquals(123456789L,l.longValue()); fault=classLoader.loadClass("org.apache.cxf.w2j.hello_world_soap_http.BadRecordLitFault"); serialVersionUID=fault.getDeclaredField("serialVersionUID"); assertNotNull(serialVersionUID); assertEquals(123456789L,l.longValue()); }

APIUtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testWsdlImport() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/hello_world_wsdl_import.wsdl")); processor.setContext(env); processor.execute(); assertNotNull(output); File org=new File(output,"org"); assertTrue(org.exists()); File apache=new File(org,"apache"); assertTrue(apache.exists()); File cxf=new File(apache,"cxf"); assertTrue(cxf.exists()); File w2j=new File(cxf,"w2j"); assertTrue(w2j.exists()); File helloWorld=new File(w2j,"hello_world"); assertTrue(helloWorld.exists()); Class clz=classLoader.loadClass("org.apache.cxf.w2j.hello_world.Greeter"); assertEquals(3,clz.getMethods().length); Method method=clz.getMethod("pingMe",new Class[]{}); assertEquals("void",method.getReturnType().getSimpleName()); assertEquals("Exception class is not generated ",1,method.getExceptionTypes().length); assertEquals("org.apache.cxf.w2j.hello_world.messages.PingMeFault",method.getExceptionTypes()[0].getCanonicalName()); }

APIUtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testWebFault() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/InvoiceServer-issue305570.wsdl")); processor.setContext(env); processor.execute(); assertNotNull(output); File org=new File(output,"org"); assertTrue(org.exists()); File apache=new File(org,"apache"); assertTrue(apache.exists()); File invoiceserver=new File(apache,"invoiceserver"); assertTrue(invoiceserver.exists()); File invoice=new File(apache,"invoice"); assertTrue(invoice.exists()); Class clz=classLoader.loadClass("org.apache.invoiceserver.NoSuchCustomerFault"); WebFault webFault=AnnotationUtil.getPrivClassAnnotation(clz,WebFault.class); assertEquals("WebFault annotaion name attribute error","NoSuchCustomer",webFault.name()); }

BranchVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testHeaderFromAnotherMessage5() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/OutOfBandHeaderBug.wsdl")); env.put(ToolConstants.CFG_EXTRA_SOAPHEADER,"TRUE"); processor.setContext(env); processor.execute(); assertNotNull(output); Class clz=classLoader.loadClass("org.apache.cxf.bugs.oobh.LoginInterface"); Method meths[]=clz.getMethods(); for ( Method m : meths) { if ("login".equals(m.getName())) { assertEquals(String.class,m.getReturnType()); assertEquals(3,m.getParameterTypes().length); assertEquals(Holder.class,m.getParameterTypes()[1]); assertEquals(Holder.class,m.getParameterTypes()[2]); } } }

APIUtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDocLitHolder() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/mapping-doc-literal.wsdl")); processor.setContext(env); processor.execute(); assertNotNull(output); File org=new File(output,"org"); assertTrue(org.exists()); File apache=new File(org,"apache"); assertTrue(apache.exists()); File mapping=new File(apache,"mapping"); assertTrue(mapping.exists()); File[] files=mapping.listFiles(); assertEquals(9,files.length); Class clz=classLoader.loadClass("org.apache.mapping.SomethingServer"); Method method=clz.getMethod("doSomething",new Class[]{int.class,javax.xml.ws.Holder.class,javax.xml.ws.Holder.class}); assertEquals("boolean",method.getReturnType().getSimpleName()); WebParam webParamAnno=AnnotationUtil.getWebParam(method,"y"); assertEquals("INOUT",webParamAnno.mode().name()); webParamAnno=AnnotationUtil.getWebParam(method,"z"); assertEquals("OUT",webParamAnno.mode().name()); }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testExceptionSuper() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/hello_world.wsdl")); env.put(ToolConstants.CFG_EXCEPTION_SUPER,"java.lang.RuntimeException"); processor.setContext(env); processor.execute(); File faultFile=new File(output,"org/apache/cxf/w2j/hello_world_soap_http/NoSuchCodeLitFault.java"); assertTrue(faultFile.exists()); faultFile=new File(output,"org/apache/cxf/w2j/hello_world_soap_http/BadRecordLitFault.java"); assertTrue(faultFile.exists()); Class fault=classLoader.loadClass("org.apache.cxf.w2j.hello_world_soap_http.NoSuchCodeLitFault"); assertEquals(RuntimeException.class,fault.getSuperclass()); }

APIUtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSoapHeader() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/soap_header.wsdl")); env.put(ToolConstants.CFG_PACKAGENAME,"org.apache"); processor.setContext(env); processor.execute(); assertNotNull(output); File org=new File(output,"org"); assertTrue(org.exists()); File apache=new File(org,"apache"); assertTrue(apache.exists()); File[] files=apache.listFiles(); assertEquals(12,files.length); Class clz=classLoader.loadClass("org.apache.HeaderTester"); assertEquals(3,clz.getMethods().length); SOAPBinding soapBindingAnno=AnnotationUtil.getPrivClassAnnotation(clz,SOAPBinding.class); assertEquals("BARE",soapBindingAnno.parameterStyle().name()); assertEquals("LITERAL",soapBindingAnno.use().name()); assertEquals("DOCUMENT",soapBindingAnno.style().name()); Class para=classLoader.loadClass("org.apache.InoutHeader"); Method method=clz.getMethod("inoutHeader",new Class[]{para,Holder.class}); WebParam webParamAnno=AnnotationUtil.getWebParam(method,"SOAPHeaderInfo"); assertEquals("INOUT",webParamAnno.mode().name()); assertEquals(true,webParamAnno.header()); assertEquals("header_info",webParamAnno.partName()); }

APIUtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testHelloWorldWithDummyPlugin() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/hello_world.wsdl")); env.put(ToolConstants.CFG_XJC_ARGS,"-" + DummyXjcPlugin.XDUMMY_XJC_PLUGIN + ",-"+ DummyXjcPlugin.XDUMMY_XJC_PLUGIN+ ":arg"); processor.setContext(env); processor.execute(); assertNotNull(output); File org=new File(output,"org"); assertTrue(org.exists()); File apache=new File(org,"apache"); assertTrue(apache.exists()); File cxf=new File(apache,"cxf"); assertTrue(cxf.exists()); File w2j=new File(cxf,"w2j"); assertTrue(w2j.exists()); File helloworldsoaphttp=new File(w2j,"hello_world_soap_http"); assertTrue(helloworldsoaphttp.exists()); File types=new File(helloworldsoaphttp,"types"); assertTrue(types.exists()); File[] files=helloworldsoaphttp.listFiles(); assertEquals(9,files.length); files=types.listFiles(); assertEquals(17,files.length); Class clz=classLoader.loadClass("org.apache.cxf.w2j.hello_world_soap_http.types.SayHi"); Method method=clz.getMethod("dummy",new Class[]{}); assertTrue("method declared on SayHi",method.getDeclaringClass().equals(clz)); }

APIUtilityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSupportXMLBindingBare() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/xml_http_bare.wsdl")); processor.setContext(env); processor.execute(); Class clz=classLoader.loadClass("org.apache.xml_http_bare.GreetingPortType"); Method method=clz.getMethod("sayHello",new Class[]{java.lang.String.class}); assertNotNull("sayHello is not be generated",method); SOAPBinding soapBindingAnn=clz.getAnnotation(SOAPBinding.class); assertEquals(soapBindingAnn.parameterStyle(),SOAPBinding.ParameterStyle.BARE); }

APIUtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testMultiSchemaParsing() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/multi_schema.wsdl")); processor.setContext(env); processor.execute(); assertNotNull(output); File org=new File(output,"org"); assertTrue(org.exists()); File tempuri=new File(org,"tempuri"); assertTrue(tempuri.exists()); File header=new File(tempuri,"header"); assertTrue(header.exists()); File[] files=header.listFiles(); assertEquals(3,files.length); }

APIUtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testImportNameCollision() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/helloworld-portname_servicename.wsdl")); env.setPackageName("org.apache"); processor.setContext(env); processor.execute(); assertNotNull(output); File org=new File(output,"org"); assertTrue(org.exists()); File apache=new File(org,"apache"); assertTrue(apache.exists()); File[] files=apache.listFiles(); assertEquals(4,files.length); File serviceCollision=new File(apache,"HelloWorldServiceImpl_Service.java"); assertTrue(serviceCollision.exists()); Class clz=classLoader.loadClass("org.apache.HelloWorldServiceImpl"); assertTrue("SEI class HelloWorldServiceImpl modifier should be interface",clz.isInterface()); clz=classLoader.loadClass("org.apache.HelloWorldServiceImpl_Service"); }

APIUtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testCXF1950() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/helloworld-noservice-header.wsdl")); processor.setContext(env); processor.execute(); File seif=new File(output,"org/apache/cxf/helloworld/HelloWorldServiceImpl.java"); assertTrue(seif.exists()); Class sei=classLoader.loadClass("org.apache.cxf.helloworld.HelloWorldServiceImpl"); Method m[]=sei.getDeclaredMethods(); assertEquals(1,m.length); assertTrue(m[0].getParameterAnnotations()[1][0] instanceof WebParam); WebParam wp=(WebParam)m[0].getParameterAnnotations()[1][0]; assertTrue(wp.header()); }

APIUtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAllNameCollision() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/hello_world_collision.wsdl")); env.put(ToolConstants.CFG_PACKAGENAME,"org.apache"); processor.setContext(env); processor.execute(); assertNotNull(output); File org=new File(output,"org"); assertTrue(org.exists()); File apache=new File(org,"apache"); assertTrue(apache.exists()); File[] files=apache.listFiles(); assertEquals(14,files.length); File typeCollision=new File(apache,"Greeter_Type.java"); assertTrue(typeCollision.exists()); File exceptionCollision=new File(apache,"Greeter_Exception.java"); assertTrue(exceptionCollision.exists()); File serviceCollision=new File(apache,"Greeter_Service.java"); assertTrue(serviceCollision.exists()); Class clz=classLoader.loadClass("org.apache.Greeter"); assertTrue("SEI class Greeter modifier should be interface",clz.isInterface()); clz=classLoader.loadClass("org.apache.Greeter_Exception"); clz=classLoader.loadClass("org.apache.Greeter_Service"); }

APIUtilityVerifier BranchVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testHelloWorldSoap12() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/hello_world_soap12.wsdl")); processor.setContext(env); processor.execute(); assertNotNull(output); File org=new File(output,"org"); assertTrue(org.exists()); File apache=new File(org,"apache"); assertTrue(apache.exists()); File cxf=new File(apache,"cxf"); assertTrue(cxf.exists()); File w2j=new File(cxf,"w2j"); assertTrue(w2j.exists()); File helloworldsoaphttp=new File(w2j,"hello_world_soap12_http"); assertTrue(helloworldsoaphttp.exists()); File types=new File(helloworldsoaphttp,"types"); assertTrue(types.exists()); File[] files=helloworldsoaphttp.listFiles(); assertEquals(5,files.length); files=types.listFiles(); assertEquals(7,files.length); Class clz=classLoader.loadClass("org.apache.cxf.w2j.hello_world_soap12_http.Greeter"); assertTrue("class " + clz.getName() + " modifier is not public",Modifier.isPublic(clz.getModifiers())); assertTrue("class " + clz.getName() + " modifier is interface",Modifier.isInterface(clz.getModifiers())); WebService webServiceAnn=AnnotationUtil.getPrivClassAnnotation(clz,WebService.class); assertEquals("Greeter",webServiceAnn.name()); Method method=clz.getMethod("sayHi",new Class[]{}); WebMethod webMethodAnno=AnnotationUtil.getPrivMethodAnnotation(method,WebMethod.class); if (webMethodAnno.operationName() != null && !"".equals(webMethodAnno.operationName())) { assertEquals(method.getName() + "()" + " Annotation : WebMethod.operationName ","sayHi",webMethodAnno.operationName()); } RequestWrapper requestWrapperAnn=AnnotationUtil.getPrivMethodAnnotation(method,RequestWrapper.class); assertEquals("org.apache.cxf.w2j.hello_world_soap12_http.types.SayHi",requestWrapperAnn.className()); ResponseWrapper resposneWrapperAnn=AnnotationUtil.getPrivMethodAnnotation(method,ResponseWrapper.class); assertEquals("sayHiResponse",resposneWrapperAnn.localName()); WebResult webResultAnno=AnnotationUtil.getPrivMethodAnnotation(method,WebResult.class); assertEquals("responseType",webResultAnno.name()); method=clz.getMethod("pingMe",new Class[]{}); webMethodAnno=AnnotationUtil.getPrivMethodAnnotation(method,WebMethod.class); if (webMethodAnno.operationName() != null && !"".equals(webMethodAnno.operationName())) { assertEquals(method.getName() + "()" + " Annotation : WebMethod.operationName ","pingMe",webMethodAnno.operationName()); } Class[] exceptionCls=method.getExceptionTypes(); assertEquals(1,exceptionCls.length); assertEquals("org.apache.cxf.w2j.hello_world_soap12_http.PingMeFault",exceptionCls[0].getName()); }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testWrapperWithWildcard() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/cxf-1404/hello_world.wsdl")); processor.setContext(env); processor.execute(); Class sei=classLoader.loadClass("org.apache.cxf.cxf1404.hello_world_soap_http.Greeter"); assertEquals(1,sei.getMethods().length); assertFalse(Void.TYPE.equals(sei.getMethods()[0].getReturnType())); }

APIUtilityVerifier UtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAsyncMethodNoService() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/hello_world_async_noservice.wsdl")); env.remove(ToolConstants.CFG_VALIDATE_WSDL); processor.setContext(env); processor.execute(); assertNotNull(output); File org=new File(output,"org"); assertTrue(org.exists()); File apache=new File(org,"apache"); assertTrue(apache.exists()); File cxf=new File(apache,"cxf"); assertTrue(cxf.exists()); File w2j=new File(cxf,"w2j"); assertTrue(w2j.exists()); File async=new File(w2j,"hello_world_async_soap_http"); assertTrue(async.exists()); File[] files=async.listFiles(); assertEquals(Arrays.asList(files).toString(),9,files.length); Class clz=classLoader.loadClass("org.apache.cxf.w2j.hello_world_async_soap_http.GreeterAsync"); Method method1=clz.getMethod("greetMeSometimeAsync",new Class[]{java.lang.String.class,javax.xml.ws.AsyncHandler.class}); WebMethod webMethodAnno1=AnnotationUtil.getPrivMethodAnnotation(method1,WebMethod.class); assertEquals(method1.getName() + "()" + " Annotation : WebMethod.operationName ","greetMeSometime",webMethodAnno1.operationName()); java.lang.reflect.Method method2=clz.getMethod("greetMeSometimeAsync",new Class[]{java.lang.String.class}); WebMethod webMethodAnno2=AnnotationUtil.getPrivMethodAnnotation(method2,WebMethod.class); assertEquals(method2.getName() + "()" + " Annotation : WebMethod.operationName ","greetMeSometime",webMethodAnno2.operationName()); method1=clz.getMethod("greetMeSometimeAsync",new Class[]{java.lang.String.class,javax.xml.ws.AsyncHandler.class}); try { method1=clz.getMethod("testIntAsync",new Class[]{Integer.TYPE,javax.xml.ws.AsyncHandler.class}); fail("Should not have generated testIntAsync"); } catch ( NoSuchMethodException ex) { } clz=classLoader.loadClass("org.apache.cxf.w2j.hello_world_async_soap_http.GreeterDAsync"); method1=clz.getMethod("greetMeSometimeAsync",new Class[]{java.lang.String.class,javax.xml.ws.AsyncHandler.class}); clz=classLoader.loadClass("org.apache.cxf.w2j.hello_world_async_soap_http.GreeterCAsync"); try { method1=clz.getMethod("greetMeSometimeAsync",new Class[]{java.lang.String.class,javax.xml.ws.AsyncHandler.class}); fail("Should not have generated greetMeSometimeAsync"); } catch ( NoSuchMethodException ex) { } method1=clz.getMethod("testIntAsync",new Class[]{Integer.TYPE,javax.xml.ws.AsyncHandler.class}); clz=classLoader.loadClass("org.apache.cxf.w2j.hello_world_async_soap_http.GreeterBAsync"); try { method1=clz.getMethod("greetMeSometimeAsync",new Class[]{java.lang.String.class,javax.xml.ws.AsyncHandler.class}); fail("Should not have generated greetMeSometimeAsync"); } catch ( NoSuchMethodException ex) { } method1=clz.getMethod("testIntAsync",new Class[]{Integer.TYPE,javax.xml.ws.AsyncHandler.class}); }

APIUtilityVerifier BranchVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testRPCHeader() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/soapheader_rpc.wsdl")); env.remove(ToolConstants.CFG_VALIDATE_WSDL); processor.setContext(env); processor.execute(); Class cls=classLoader.loadClass("org.apache.header_test.rpc.TestRPCHeaderPort"); Method meths[]=cls.getMethods(); for ( Method m : meths) { if ("testHeader1".equals(m.getName())) { Annotation annotations[][]=m.getParameterAnnotations(); assertEquals(2,annotations.length); assertEquals(1,annotations[1].length); assertTrue(annotations[1][0] instanceof WebParam); WebParam parm=(WebParam)annotations[1][0]; assertEquals("http://apache.org/header_test/rpc/types",parm.targetNamespace()); assertEquals("inHeader",parm.partName()); assertEquals("headerMessage",parm.name()); assertTrue(parm.header()); } } for ( Method m : meths) { if ("testInOutHeader".equals(m.getName())) { Annotation annotations[][]=m.getParameterAnnotations(); assertEquals(2,annotations.length); assertEquals(1,annotations[1].length); assertTrue(annotations[1][0] instanceof WebParam); WebParam parm=(WebParam)annotations[1][0]; assertEquals("http://apache.org/header_test/rpc/types",parm.targetNamespace()); assertEquals("inOutHeader",parm.partName()); assertEquals("headerMessage",parm.name()); assertTrue(parm.header()); } } }

APIUtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAsyncMethodFromCommandLine() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/hello_world.wsdl")); env.put(ToolConstants.CFG_ASYNCMETHODS,new String[0]); processor.setContext(env); processor.execute(); assertNotNull(output); File org=new File(output,"org"); assertTrue(org.exists()); File apache=new File(org,"apache"); assertTrue(apache.exists()); File cxf=new File(apache,"cxf"); assertTrue(cxf.exists()); File w2j=new File(cxf,"w2j"); assertTrue(w2j.exists()); File async=new File(w2j,"hello_world_soap_http"); assertTrue(async.exists()); File[] files=async.listFiles(); assertEquals(9,files.length); Class clz=classLoader.loadClass("org.apache.cxf.w2j.hello_world_soap_http.Greeter"); Method method1=clz.getMethod("greetMeSometimeAsync",new Class[]{java.lang.String.class,javax.xml.ws.AsyncHandler.class}); WebMethod webMethodAnno1=AnnotationUtil.getPrivMethodAnnotation(method1,WebMethod.class); assertEquals(method1.getName() + "()" + " Annotation : WebMethod.operationName ","greetMeSometime",webMethodAnno1.operationName()); java.lang.reflect.Method method2=clz.getMethod("greetMeSometimeAsync",new Class[]{java.lang.String.class}); WebMethod webMethodAnno2=AnnotationUtil.getPrivMethodAnnotation(method2,WebMethod.class); assertEquals(method2.getName() + "()" + " Annotation : WebMethod.operationName ","greetMeSometime",webMethodAnno2.operationName()); }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testNoExceptionSuper() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/hello_world.wsdl")); processor.setContext(env); processor.execute(); File faultFile=new File(output,"org/apache/cxf/w2j/hello_world_soap_http/NoSuchCodeLitFault.java"); assertTrue(faultFile.exists()); faultFile=new File(output,"org/apache/cxf/w2j/hello_world_soap_http/BadRecordLitFault.java"); assertTrue(faultFile.exists()); Class fault=classLoader.loadClass("org.apache.cxf.w2j.hello_world_soap_http.NoSuchCodeLitFault"); assertEquals(Exception.class,fault.getSuperclass()); }

APIUtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testRPCLit() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/hello_world_rpc_lit.wsdl")); processor.setContext(env); processor.execute(); assertNotNull(output); File org=new File(output,"org"); assertTrue(org.exists()); File apache=new File(org,"apache"); assertTrue(apache.exists()); File cxf=new File(apache,"cxf"); assertTrue(cxf.exists()); File w2j=new File(cxf,"w2j"); assertTrue(w2j.exists()); File helloworldsoaphttp=new File(w2j,"hello_world_rpclit"); assertTrue(helloworldsoaphttp.exists()); File types=new File(helloworldsoaphttp,"types"); assertTrue(types.exists()); File[] files=helloworldsoaphttp.listFiles(); assertEquals(4,files.length); files=types.listFiles(); assertEquals(files.length,3); Class clz=classLoader.loadClass("org.apache.cxf.w2j.hello_world_rpclit.GreeterRPCLit"); javax.jws.WebService ws=AnnotationUtil.getPrivClassAnnotation(clz,javax.jws.WebService.class); SOAPBinding soapBindingAnno=AnnotationUtil.getPrivClassAnnotation(clz,SOAPBinding.class); assertEquals("LITERAL",soapBindingAnno.use().toString()); assertEquals("RPC",soapBindingAnno.style().toString()); assertEquals("Generate operation error",3,clz.getMethods().length); Class paraClass=classLoader.loadClass("org.apache.cxf.w2j.hello_world_rpclit.types.MyComplexStruct"); Method method=clz.getMethod("sendReceiveData",new Class[]{paraClass}); assertEquals("MyComplexStruct",method.getReturnType().getSimpleName()); clz=classLoader.loadClass("org.apache.cxf.w2j.hello_world_rpclit.SoapPortRPCLitImpl"); assertNotNull(clz); ws=AnnotationUtil.getPrivClassAnnotation(clz,javax.jws.WebService.class); assertNotNull(ws); assertTrue("Webservice annotation wsdlLocation should begin with file",ws.wsdlLocation().startsWith("file")); assertEquals("org.apache.cxf.w2j.hello_world_rpclit.GreeterRPCLit",ws.endpointInterface()); }

APIUtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAsyncMethod() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/hello_world_async.wsdl")); processor.setContext(env); processor.execute(); assertNotNull(output); File org=new File(output,"org"); assertTrue(org.exists()); File apache=new File(org,"apache"); assertTrue(apache.exists()); File cxf=new File(apache,"cxf"); assertTrue(cxf.exists()); File w2j=new File(cxf,"w2j"); assertTrue(w2j.exists()); File async=new File(w2j,"hello_world_async_soap_http"); assertTrue(async.exists()); File[] files=async.listFiles(); assertEquals(4,files.length); Class clz=classLoader.loadClass("org.apache.cxf.w2j.hello_world_async_soap_http.GreeterAsync"); Method method1=clz.getMethod("greetMeSometimeAsync",new Class[]{java.lang.String.class,javax.xml.ws.AsyncHandler.class}); WebMethod webMethodAnno1=AnnotationUtil.getPrivMethodAnnotation(method1,WebMethod.class); assertEquals(method1.getName() + "()" + " Annotation : WebMethod.operationName ","greetMeSometime",webMethodAnno1.operationName()); java.lang.reflect.Method method2=clz.getMethod("greetMeSometimeAsync",new Class[]{java.lang.String.class}); WebMethod webMethodAnno2=AnnotationUtil.getPrivMethodAnnotation(method2,WebMethod.class); assertEquals(method2.getName() + "()" + " Annotation : WebMethod.operationName ","greetMeSometime",webMethodAnno2.operationName()); }

APIUtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testExceptionNameCollision() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/InvoiceServer.wsdl")); processor.setContext(env); processor.execute(); assertNotNull(output); File org=new File(output,"org"); assertTrue(org.exists()); File apache=new File(org,"apache"); assertTrue(apache.exists()); File invoiceserver=new File(apache,"invoiceserver"); assertTrue(invoiceserver.exists()); File invoice=new File(apache,"invoice"); assertTrue(invoice.exists()); File exceptionCollision=new File(invoiceserver,"NoSuchCustomerFault_Exception.java"); assertTrue(exceptionCollision.exists()); File[] files=invoiceserver.listFiles(); assertEquals(13,files.length); files=invoice.listFiles(); assertEquals(files.length,9); Class clz=classLoader.loadClass("org.apache.invoiceserver.InvoiceServer"); assertEquals(3,clz.getMethods().length); Method method=clz.getMethod("getInvoicesForCustomer",new Class[]{String.class,String.class}); assertEquals("NoSuchCustomerFault_Exception",method.getExceptionTypes()[0].getSimpleName()); }

APIUtilityVerifier IterativeVerifier BranchVerifier UtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testHeaderFromAnotherMessage1() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/pizza.wsdl")); env.put(ToolConstants.CFG_EXTRA_SOAPHEADER,"TRUE"); env.remove(ToolConstants.CFG_VALIDATE_WSDL); processor.setContext(env); processor.execute(); assertNotNull(output); Class clz=classLoader.loadClass("com.mypizzaco.pizza.PizzaPortType"); Method meths[]=clz.getMethods(); for ( Method m : meths) { if ("orderPizzaBroken".equals(m.getName())) { Annotation annotations[][]=m.getParameterAnnotations(); assertEquals(2,annotations.length); for (int i=0; i < 2; i++) { assertTrue(annotations[i][0] instanceof WebParam); WebParam parm=(WebParam)annotations[i][0]; if ("OrderPizza".equals(parm.name())) { assertEquals("http://mypizzaco.com/pizza/types",parm.targetNamespace()); assertEquals("OrderPizza",parm.name()); assertTrue(!parm.header()); } else if ("CallerIDHeader".equals(parm.name())) { assertEquals("http://mypizzaco.com/pizza/types",parm.targetNamespace()); assertEquals("callerID",parm.partName()); assertEquals("CallerIDHeader",parm.name()); assertTrue(parm.header()); } else { fail("No WebParam found!"); } } } if ("orderPizza".equals(m.getName())) { Annotation annotations[][]=m.getParameterAnnotations(); assertEquals(2,annotations.length); for (int i=0; i < 2; i++) { assertTrue(annotations[i][0] instanceof WebParam); WebParam parm=(WebParam)annotations[i][0]; if ("OrderPizza".equals(parm.name())) { assertEquals("http://mypizzaco.com/pizza/types",parm.targetNamespace()); assertEquals("OrderPizza",parm.name()); assertTrue(!parm.header()); } else if ("CallerIDHeader".equals(parm.name())) { assertEquals("http://mypizzaco.com/pizza/types",parm.targetNamespace()); assertEquals("callerID",parm.partName()); assertEquals("CallerIDHeader",parm.name()); assertTrue(parm.header()); } else { fail("No WebParam found!"); } } } } }

APIUtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testWSAddress() throws Exception { env.addNamespacePackageMap("http://cxf.apache.org/w2j/hello_world_soap_http","ws.address"); env.put(ToolConstants.CFG_BINDING,getLocation("/wsdl2java_wsdl/ws_address_binding.wsdl")); env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/hello_world_addr.wsdl")); processor.setContext(env); processor.execute(); assertNotNull(output); File ws=new File(output,"ws"); assertTrue(ws.exists()); File address=new File(ws,"address"); assertTrue(address.exists()); File[] files=address.listFiles(); assertEquals(Arrays.asList(address.listFiles()).toString(),6,files.length); File handlerConfig=new File(address,"Greeter_handler.xml"); assertTrue(handlerConfig.exists()); Class clz=classLoader.loadClass("ws.address.Greeter"); HandlerChain handlerChainAnno=AnnotationUtil.getPrivClassAnnotation(clz,HandlerChain.class); assertEquals("Greeter_handler.xml",handlerChainAnno.file()); assertNotNull("Handler chain xml generate fail!",classLoader.getResource("ws/address/Greeter_handler.xml")); }

APIUtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testRefTNS() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/locator.wsdl")); processor.setContext(env); processor.execute(); assertNotNull(output); File org=new File(output,"org"); assertTrue(org.exists()); File apache=new File(org,"apache"); assertTrue(apache.exists()); File locator=new File(apache,"locator"); assertTrue(locator.exists()); File locatorService=new File(locator,"LocatorService.java"); assertTrue(locatorService.exists()); Class clz=classLoader.loadClass("org.apache.locator.LocatorService"); Class paraClass=classLoader.loadClass("org.apache.locator.types.QueryEndpoints"); Method method=clz.getMethod("queryEndpoints",new Class[]{paraClass}); WebResult webRes=AnnotationUtil.getPrivMethodAnnotation(method,WebResult.class); assertEquals("http://apache.org/locator/types",webRes.targetNamespace()); assertEquals("queryEndpointsResponse",webRes.name()); WebParam webParamAnn=AnnotationUtil.getWebParam(method,"queryEndpoints"); assertEquals("http://apache.org/locator/types",webParamAnn.targetNamespace()); method=clz.getMethod("deregisterPeerManager",new Class[]{String.class}); webParamAnn=AnnotationUtil.getWebParam(method,"node_id"); assertEquals("",webParamAnn.targetNamespace()); }

APIUtilityVerifier IterativeVerifier BranchVerifier UtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testHeaderFromAnotherMessage2() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/pizza.wsdl")); env.remove(ToolConstants.CFG_VALIDATE_WSDL); processor.setContext(env); processor.execute(); assertNotNull(output); Class clz=classLoader.loadClass("com.mypizzaco.pizza.PizzaPortType"); Method meths[]=clz.getMethods(); for ( Method m : meths) { if ("orderPizzaBroken".equals(m.getName())) { Annotation annotations[][]=m.getParameterAnnotations(); assertEquals(1,annotations.length); for (int i=0; i < 1; i++) { assertTrue(annotations[i][0] instanceof WebParam); WebParam parm=(WebParam)annotations[i][0]; if ("OrderPizza".equals(parm.name())) { assertEquals("http://mypizzaco.com/pizza/types",parm.targetNamespace()); assertEquals("OrderPizza",parm.name()); assertTrue(!parm.header()); } else if ("CallerIDHeader".equals(parm.name())) { fail("If the exsh turned off, should not generate this parameter"); } else { fail("No WebParam found!"); } } } } }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testClientJar() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/hello_world_wsdl_import.wsdl")); env.put(ToolConstants.CFG_CLIENT_JAR,"test-client.jar"); processor.setContext(env); processor.execute(); File clientjarFile=new File(output,"test-client.jar"); assertTrue(clientjarFile.exists()); List jarEntries=new ArrayList(); JarInputStream jarIns=new JarInputStream(new FileInputStream(clientjarFile)); JarEntry entry=null; while ((entry=jarIns.getNextJarEntry()) != null) { if (entry.getName().endsWith(".wsdl") || entry.getName().endsWith(".class")) { jarEntries.add(entry.getName()); } } jarIns.close(); assertEquals("15 files including wsdl and class files are expected",15,jarEntries.size()); assertTrue("hello_world_messages.wsdl is expected",jarEntries.contains("hello_world_messages.wsdl")); assertTrue("org/apache/cxf/w2j/hello_world/SOAPService.class is expected",jarEntries.contains("org/apache/cxf/w2j/hello_world/SOAPService.class")); }

APIUtilityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testHolderHeader() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/hello_world_holder.wsdl")); env.remove(ToolConstants.CFG_VALIDATE_WSDL); processor.setContext(env); processor.execute(); Class clz=classLoader.loadClass("org.apache.cxf.w2j.hello_world_holder.Greeter"); assertEquals(2,clz.getMethods().length); Class para=classLoader.loadClass("org.apache.cxf.w2j.hello_world_holder.types.GreetMe"); Method method=clz.getMethod("sayHi",new Class[]{Holder.class,para}); assertEquals("GreetMeResponse",method.getReturnType().getSimpleName()); SOAPBinding soapBindingAnno=AnnotationUtil.getPrivClassAnnotation(clz,SOAPBinding.class); if (soapBindingAnno == null) { soapBindingAnno=method.getAnnotation(SOAPBinding.class); } assertNotNull(soapBindingAnno); assertEquals("BARE",soapBindingAnno.parameterStyle().name()); assertEquals("LITERAL",soapBindingAnno.use().name()); assertEquals("DOCUMENT",soapBindingAnno.style().name()); WebParam webParamAnno=AnnotationUtil.getWebParam(method,"greetMe"); assertEquals(true,webParamAnno.header()); webParamAnno=AnnotationUtil.getWebParam(method,"sayHi"); assertEquals("INOUT",webParamAnno.mode().name()); method=clz.getMethod("testInOut",Holder.class,Integer.TYPE); }

APIUtilityVerifier BranchVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testHelloWorld() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/hello_world.wsdl")); processor.setContext(env); processor.execute(); assertNotNull(output); File org=new File(output,"org"); assertTrue(org.exists()); File apache=new File(org,"apache"); assertTrue(apache.exists()); File cxf=new File(apache,"cxf"); assertTrue(cxf.exists()); File w2j=new File(cxf,"w2j"); assertTrue(w2j.exists()); File helloworldsoaphttp=new File(w2j,"hello_world_soap_http"); assertTrue(helloworldsoaphttp.exists()); File types=new File(helloworldsoaphttp,"types"); assertTrue(types.exists()); File[] files=helloworldsoaphttp.listFiles(); assertEquals(9,files.length); files=types.listFiles(); assertEquals(17,files.length); Class clz=classLoader.loadClass("org.apache.cxf.w2j.hello_world_soap_http.Greeter"); assertTrue("class " + clz.getName() + " modifier is not public",Modifier.isPublic(clz.getModifiers())); assertTrue("class " + clz.getName() + " modifier is interface",Modifier.isInterface(clz.getModifiers())); WebService webServiceAnn=AnnotationUtil.getPrivClassAnnotation(clz,WebService.class); assertEquals("Greeter",webServiceAnn.name()); Method method=clz.getMethod("sayHi",new Class[]{}); WebMethod webMethodAnno=AnnotationUtil.getPrivMethodAnnotation(method,WebMethod.class); if (webMethodAnno.operationName() != null && !"".equals(webMethodAnno.operationName())) { assertEquals(method.getName() + "()" + " Annotation : WebMethod.operationName ","sayHi",webMethodAnno.operationName()); } RequestWrapper requestWrapperAnn=AnnotationUtil.getPrivMethodAnnotation(method,RequestWrapper.class); assertEquals("org.apache.cxf.w2j.hello_world_soap_http.types.SayHi",requestWrapperAnn.className()); ResponseWrapper resposneWrapperAnn=AnnotationUtil.getPrivMethodAnnotation(method,ResponseWrapper.class); assertEquals("sayHiResponse",resposneWrapperAnn.localName()); WebResult webResultAnno=AnnotationUtil.getPrivMethodAnnotation(method,WebResult.class); assertEquals("responseType",webResultAnno.name()); method=clz.getMethod("greetMe",new Class[]{String.class}); assertEquals("String",method.getReturnType().getSimpleName()); WebParam webParamAnn=AnnotationUtil.getWebParam(method,"requestType"); assertEquals("http://cxf.apache.org/w2j/hello_world_soap_http/types",webParamAnn.targetNamespace()); method=clz.getMethod("greetMeOneWay",new Class[]{String.class}); Oneway oneWayAnn=AnnotationUtil.getPrivMethodAnnotation(method,Oneway.class); assertNotNull("OneWay Annotation is not generated",oneWayAnn); assertEquals("void",method.getReturnType().getSimpleName()); method=clz.getMethod("greetMeSometime",new Class[]{String.class}); assertEquals("String",method.getReturnType().getSimpleName()); method=clz.getMethod("testDocLitFault",new Class[]{java.lang.String.class}); assertEquals("void",method.getReturnType().getSimpleName()); assertEquals("Exception class is not generated ",2,method.getExceptionTypes().length); method=clz.getMethod("testDocLitBare",new Class[]{java.lang.String.class}); webResultAnno=AnnotationUtil.getPrivMethodAnnotation(method,WebResult.class); assertEquals("out",webResultAnno.partName()); SOAPBinding soapBindingAnno=AnnotationUtil.getPrivMethodAnnotation(method,SOAPBinding.class); assertNotNull(soapBindingAnno); assertEquals(SOAPBinding.ParameterStyle.BARE,soapBindingAnno.parameterStyle()); assertEquals("BareDocumentResponse",method.getReturnType().getSimpleName()); }

APIUtilityVerifier BranchVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testVoidInOutMethod() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/interoptestdoclit.wsdl")); env.remove(ToolConstants.CFG_VALIDATE_WSDL); processor.setContext(env); processor.execute(); assertNotNull(output); File org=new File(output,"org"); assertTrue(org.exists()); File soapinterop=new File(org,"soapinterop"); assertTrue(soapinterop.exists()); File wsdlinterop=new File(soapinterop,"wsdlinteroptestdoclit"); assertTrue(wsdlinterop.exists()); File xsd=new File(soapinterop,"xsd"); assertTrue(xsd.exists()); File[] files=wsdlinterop.listFiles(); assertEquals(3,files.length); files=xsd.listFiles(); assertEquals(4,files.length); Class clz=classLoader.loadClass("org.soapinterop.wsdlinteroptestdoclit.WSDLInteropTestDocLitPortType"); Method method=clz.getMethod("echoVoid",new Class[]{}); WebMethod webMethodAnno=AnnotationUtil.getPrivMethodAnnotation(method,WebMethod.class); if (webMethodAnno.operationName() != null && !"".equals(webMethodAnno.operationName())) { assertEquals(method.getName() + "()" + " Annotation : WebMethod.operationName ","echoVoid",webMethodAnno.operationName()); } }

APIUtilityVerifier IterativeVerifier BranchVerifier UtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testHeaderFromAnotherMessage3() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/pizza.wsdl")); env.put(ToolConstants.CFG_EXTRA_SOAPHEADER,"FALSE"); env.remove(ToolConstants.CFG_VALIDATE_WSDL); processor.setContext(env); processor.execute(); assertNotNull(output); Class clz=classLoader.loadClass("com.mypizzaco.pizza.PizzaPortType"); Method meths[]=clz.getMethods(); for ( Method m : meths) { if ("orderPizzaBroken".equals(m.getName())) { Annotation annotations[][]=m.getParameterAnnotations(); assertEquals(1,annotations.length); for (int i=0; i < 1; i++) { assertTrue(annotations[i][0] instanceof WebParam); WebParam parm=(WebParam)annotations[i][0]; if ("OrderPizza".equals(parm.name())) { assertEquals("http://mypizzaco.com/pizza/types",parm.targetNamespace()); assertEquals("OrderPizza",parm.name()); assertTrue(!parm.header()); } else if ("CallerIDHeader".equals(parm.name())) { fail("If the exsh turned off, should not generate this parameter"); } else { fail("No WebParam found!"); } } } } }

APIUtilityVerifier BooleanVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSchemaImport() throws Exception { env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/hello_world_schema_import.wsdl")); processor.setContext(env); processor.execute(); assertNotNull(output); File org=new File(output,"org"); assertTrue(org.exists()); File apache=new File(org,"apache"); assertTrue(apache.exists()); File cxf=new File(apache,"cxf"); assertTrue(cxf.exists()); File w2j=new File(cxf,"w2j"); assertTrue(w2j.exists()); File[] files=w2j.listFiles(); File helloworldsoaphttp=new File(w2j,"hello_world_soap_http"); assertTrue(helloworldsoaphttp.exists()); File types=new File(helloworldsoaphttp,"types"); assertTrue(types.exists()); files=helloworldsoaphttp.listFiles(); assertEquals(1,files.length); files=types.listFiles(); assertEquals(files.length,10); File schemaImport=new File(apache,"schema_import"); assertTrue(schemaImport.exists()); files=schemaImport.listFiles(); assertEquals(4,files.length); Class clz=classLoader.loadClass("org.apache.schema_import.Greeter"); assertEquals(4,clz.getMethods().length); Method method=clz.getMethod("pingMe",new Class[]{}); assertEquals("void",method.getReturnType().getSimpleName()); assertEquals("Exception class is not generated ",1,method.getExceptionTypes().length); }

Class: org.apache.cxf.tools.wsdlto.jaxws.JAXWSContainerTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCodeGen(){ try { JAXWSContainer container=new JAXWSContainer(null); ToolContext context=new ToolContext(); context.put(ToolConstants.CFG_OUTPUTDIR,output.getCanonicalPath()); context.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/hello_world.wsdl")); context.put(DataBindingProfile.class,PluginLoader.getInstance().getDataBindingProfile("jaxb")); context.put(FrontEndProfile.class,PluginLoader.getInstance().getFrontEndProfile("jaxws")); List generatorNames=Arrays.asList(new String[]{ToolConstants.CLT_GENERATOR,ToolConstants.SVR_GENERATOR,ToolConstants.IMPL_GENERATOR,ToolConstants.ANT_GENERATOR,ToolConstants.SERVICE_GENERATOR,ToolConstants.FAULT_GENERATOR,ToolConstants.SEI_GENERATOR}); FrontEndProfile frontend=context.get(FrontEndProfile.class); List generators=frontend.getGenerators(); for ( FrontEndGenerator generator : generators) { assertTrue(generatorNames.contains(generator.getName())); } container.setContext(context); container.execute(); assertNotNull(output.list()); assertEquals(1,output.list().length); assertTrue(new File(output,"org/apache/cxf/w2j/hello_world_soap_http/Greeter.java").exists()); assertTrue(new File(output,"org/apache/cxf/w2j/hello_world_soap_http/SOAPService.java").exists()); assertTrue(new File(output,"org/apache/cxf/w2j/hello_world_soap_http/NoSuchCodeLitFault.java").exists()); assertTrue(new File(output,"org/apache/cxf/w2j/hello_world_soap_http/types/SayHi.java").exists()); assertTrue(new File(output,"org/apache/cxf/w2j/hello_world_soap_http/types/GreetMe.java").exists()); JavaModel javaModel=context.get(JavaModel.class); Map interfaces=javaModel.getInterfaces(); assertEquals(1,interfaces.size()); JavaInterface intf=interfaces.values().iterator().next(); assertEquals("http://cxf.apache.org/w2j/hello_world_soap_http",intf.getNamespace()); assertEquals("Greeter",intf.getName()); assertEquals("org.apache.cxf.w2j.hello_world_soap_http",intf.getPackageName()); List methods=intf.getMethods(); assertEquals(6,methods.size()); Boolean methodSame=false; for ( JavaMethod m1 : methods) { if (m1.getName().equals("testDocLitFault")) { methodSame=true; break; } } assertTrue(methodSame); } catch ( Exception e) { e.printStackTrace(); } }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSuppressCodeGen(){ try { JAXWSContainer container=new JAXWSContainer(null); ToolContext context=new ToolContext(); context.put(ToolConstants.CFG_SUPPRESS_GEN,"suppress"); context.put(ToolConstants.CFG_OUTPUTDIR,output.getCanonicalPath()); context.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/hello_world.wsdl")); context.put(DataBindingProfile.class,PluginLoader.getInstance().getDataBindingProfile("jaxb")); context.put(FrontEndProfile.class,PluginLoader.getInstance().getFrontEndProfile("jaxws")); container.setContext(context); container.execute(); assertNotNull(output.list()); assertEquals(0,output.list().length); Map map=CastUtils.cast((Map)context.get(WSDLToJavaProcessor.MODEL_MAP)); JavaModel javaModel=map.get(new QName("http://cxf.apache.org/w2j/hello_world_soap_http","SOAPService")); assertNotNull(javaModel); Map interfaces=javaModel.getInterfaces(); assertEquals(1,interfaces.size()); JavaInterface intf=interfaces.values().iterator().next(); String interfaceName=intf.getName(); assertEquals("Greeter",interfaceName); assertEquals("http://cxf.apache.org/w2j/hello_world_soap_http",intf.getNamespace()); assertEquals("org.apache.cxf.w2j.hello_world_soap_http",intf.getPackageName()); List methods=intf.getMethods(); assertEquals(6,methods.size()); Boolean methodSame=false; JavaMethod m1=null; for ( JavaMethod m2 : methods) { if (m2.getName().equals("testDocLitFault")) { methodSame=true; m1=m2; break; } } assertTrue(methodSame); assertEquals(2,m1.getExceptions().size()); List names=new ArrayList(); for ( JavaException exc : m1.getExceptions()) { names.add(exc.getName()); } assertTrue("BadRecordLitFault",names.contains("BadRecordLitFault")); assertTrue("NoSuchCodeLitFault",names.contains("NoSuchCodeLitFault")); String address=null; for ( JavaServiceClass service : javaModel.getServiceClasses().values()) { if ("SOAPService_Test1".equals(service.getName())) { continue; } List ports=service.getPorts(); for ( JavaPort port : ports) { if (interfaceName.equals(port.getPortType())) { address=port.getBindingAdress(); break; } } if (!"".equals(address)) { break; } } assertEquals("http://localhost:9000/SoapContext/SoapPort",address); } catch ( Exception e) { e.printStackTrace(); } }

Class: org.apache.cxf.tools.wsdlto.jaxws.wsdl11.JAXWSDefinitionBuilderTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBuildDefinitionWithXMLBinding(){ String qname="http://apache.org/hello_world_xml_http/bare"; String wsdlUrl=getClass().getResource("resources/hello_world_xml_bare.wsdl").toString(); JAXWSDefinitionBuilder builder=new JAXWSDefinitionBuilder(); builder.setBus(BusFactory.getDefaultBus()); builder.setContext(env); Definition def=builder.build(wsdlUrl); assertNotNull(def); Map services=def.getServices(); assertNotNull(services); assertEquals(1,services.size()); Service service=(Service)services.get(new QName(qname,"XMLService")); assertNotNull(service); Map ports=service.getPorts(); assertNotNull(ports); assertEquals(1,ports.size()); Port port=service.getPort("XMLPort"); assertNotNull(port); assertEquals(1,port.getExtensibilityElements().size()); Object obj=port.getExtensibilityElements().get(0); if (obj instanceof JAXBExtensibilityElement) { obj=((JAXBExtensibilityElement)obj).getValue(); } assertTrue(obj.getClass().getName() + " is not an AddressType",obj instanceof AddressType); Binding binding=port.getBinding(); assertNotNull(binding); assertEquals(new QName(qname,"Greeter_XMLBinding"),binding.getQName()); BindingOperation operation=binding.getBindingOperation("sayHi",null,null); assertNotNull(operation); BindingInput input=operation.getBindingInput(); assertNotNull(input); assertEquals(1,input.getExtensibilityElements().size()); obj=input.getExtensibilityElements().get(0); if (obj instanceof JAXBExtensibilityElement) { obj=((JAXBExtensibilityElement)obj).getValue(); } assertTrue(obj.getClass().getName() + " is not an XMLBindingMessageFormat",obj instanceof XMLBindingMessageFormat); }

Class: org.apache.cxf.tools.wsdlto.validator.ValidatorTest

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testXMLFormat() throws Exception { processor=new JAXWSContainer(null); env.put(ToolConstants.CFG_WSDLURL,getLocation("/wsdl2java_wsdl/xml_format_root.wsdl")); processor.setContext(env); try { processor.execute(); fail("xml_format_root.wsdl is not a valid wsdl, should throws exception here"); } catch ( Exception e) { String expected="Binding(Greeter_XMLBinding):BindingOperation" + "({http://apache.org/xml_http_bare}sayHi)-input: empty value of rootNode attribute, " + "the value should be {http://apache.org/xml_http_bare}sayHi"; assertEquals(expected,e.getMessage().trim()); } }

Class: org.apache.cxf.transport.HttpUriMapperTest

APIUtilityVerifier EqualityVerifier 
@Test public void testGetResourceBase() throws Exception { URL url=new URL("http://localhost:8080/SoapContext/SoapPort"); String path=url.getPath(); assertEquals("/SoapPort",HttpUriMapper.getResourceBase(path)); url=new URL("http://localhost:8080/SoapContext/SoapPort/"); path=url.getPath(); assertEquals("/",HttpUriMapper.getResourceBase(path)); url=new URL("http://localhost:8080/SoapPort"); path=url.getPath(); assertEquals("/SoapPort",HttpUriMapper.getResourceBase(path)); }

APIUtilityVerifier EqualityVerifier 
@Test public void testGetContext() throws Exception { URL url=new URL("http://localhost:8080/SoapContext/SoapPort"); String path=url.getPath(); assertEquals("/SoapContext",HttpUriMapper.getContextName(path)); url=new URL("http://localhost:8080/SoapContext/SoapPort/"); path=url.getPath(); assertEquals("/SoapContext/SoapPort",HttpUriMapper.getContextName(path)); url=new URL("http://localhost:8080/"); path=url.getPath(); assertEquals("",HttpUriMapper.getContextName(path)); }

Class: org.apache.cxf.transport.http.CXFAuthenticatorCleanupTest

APIUtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void runCleanupTestStrongRef() throws Exception { final List traceLengths=new ArrayList(); Authenticator.setDefault(new Authenticator(){ protected PasswordAuthentication getPasswordAuthentication(){ traceLengths.add(Thread.currentThread().getStackTrace().length); return super.getPasswordAuthentication(); } } ); InetAddress add=InetAddress.getLocalHost(); Authenticator.requestPasswordAuthentication("localhost",add,8080,"http","hello","http"); List list=new ArrayList(); for (int x=0; x < 20; x++) { CXFAuthenticator.addAuthenticator(); list.add(CXFAuthenticator.instance); CXFAuthenticator.instance=null; } Authenticator.requestPasswordAuthentication("localhost",add,8080,"http","hello","http"); for (int x=9; x > 0; x-=2) { list.remove(x); } for (int x=0; x < 10; x++) { System.gc(); Authenticator.requestPasswordAuthentication("localhost",add,8080,"http","hello","http"); } list.clear(); for (int x=0; x < 10; x++) { System.gc(); Authenticator.requestPasswordAuthentication("localhost",add,8080,"http","hello","http"); } Assert.assertEquals(22,traceLengths.size()); int raw=traceLengths.get(0); int all=traceLengths.get(1); int some=traceLengths.get(11); int none=traceLengths.get(traceLengths.size() - 1); Assert.assertTrue(all > (raw + 20 * 3)); Assert.assertTrue(all > raw); Assert.assertTrue(all > some); Assert.assertTrue(some > none); Assert.assertEquals(raw,none); }

APIUtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void runCleanupTestWeakRef() throws Exception { InetAddress add=InetAddress.getLocalHost(); final List traceLengths=new ArrayList(); Authenticator.setDefault(new Authenticator(){ protected PasswordAuthentication getPasswordAuthentication(){ traceLengths.add(Thread.currentThread().getStackTrace().length); return super.getPasswordAuthentication(); } } ); Authenticator.requestPasswordAuthentication("localhost",add,8080,"http","hello","http"); for (int x=0; x < 20; x++) { CXFAuthenticator.addAuthenticator(); CXFAuthenticator.instance=null; System.gc(); } CXFAuthenticator.addAuthenticator(); System.gc(); Authenticator.requestPasswordAuthentication("localhost",add,8080,"http","hello","http"); CXFAuthenticator.instance=null; for (int x=0; x < 10; x++) { System.gc(); Authenticator.requestPasswordAuthentication("localhost",add,8080,"http","hello","http"); } Assert.assertEquals(12,traceLengths.size()); int raw=traceLengths.get(0); int one=traceLengths.get(1); int none=traceLengths.get(traceLengths.size() - 1); Assert.assertTrue(one < (raw + (20 * 2))); Assert.assertTrue(one > raw); Assert.assertTrue(one > none); Assert.assertEquals(raw,none); }

Class: org.apache.cxf.transport.http.DestinationRegistryImplTest

IterativeVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAddAndGetDestinations() throws Exception { setUpDestinations(); Set paths=registry.getDestinationsPaths(); assertEquals(REGISTERED_PATHS.length,paths.size()); for (int i=0; i < REGISTERED_PATHS.length; i++) { assertTrue(paths.contains(REGISTERED_PATHS[i])); AbstractHTTPDestination path=registry.getDestinationForPath(REGISTERED_PATHS[i]); assertNotNull(path); } }

IterativeVerifier BranchVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCheckRestfulRequest() throws Exception { setUpDestinations(); for (int i=0; i < REQUEST_PATHS.length; i++) { final int mi=MATCHED_PATH_INDEXES[i]; for (int j=0; j < REGISTERED_PATHS.length; j++) { AbstractHTTPDestination target=registry.getDestinationForPath(REGISTERED_PATHS[j]); if (mi == j) { EasyMock.expect(target.getMessageObserver()).andReturn(observer); EndpointInfo endpoint=new EndpointInfo(); endpoint.setAddress(REGISTERED_PATHS[mi]); endpoint.setName(QNAME); EasyMock.expect(target.getEndpointInfo()).andReturn(endpoint); } else { EasyMock.expect(target.getMessageObserver()).andReturn(observer).anyTimes(); } } control.replay(); AbstractHTTPDestination destination=registry.checkRestfulRequest(REQUEST_PATHS[i]); if (0 <= mi) { EndpointInfo endpoint=destination.getEndpointInfo(); assertNotNull(endpoint); assertEquals(endpoint.getAddress(),REGISTERED_PATHS[mi]); } else { assertNull(destination); } control.verify(); control.reset(); } }

Class: org.apache.cxf.transport.http.HTTPConduitTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAuthPolicyFromEndpointInfo() throws Exception { Bus bus=new ExtensionManagerBus(); EndpointInfo ei=new EndpointInfo(); AuthorizationPolicy ap=new AuthorizationPolicy(); ap.setPassword("password"); ap.setUserName("testUser"); ei.addExtensor(ap); ei.setAddress("http://nowhere.com/bar/foo"); HTTPConduit conduit=new URLConnectionHTTPConduit(bus,ei,null); conduit.finalizeConfig(); Message message=getNewMessage(); conduit.prepare(message); Map> headers=CastUtils.cast((Map)message.get(Message.PROTOCOL_HEADERS)); assertNotNull("Authorization Header should exist",headers.get("Authorization")); assertEquals("Unexpected Authorization Token","Basic " + Base64Utility.encode("testUser:password".getBytes()),headers.get("Authorization").get(0)); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
/** * This test verfies that the "getTarget() call returns the correct * EndpointReferenceType for the given endpoint address. */ @Test public void testGetTarget() throws Exception { Bus bus=new ExtensionManagerBus(); EndpointInfo ei=new EndpointInfo(); ei.setAddress("http://nowhere.com/bar/foo"); HTTPConduit conduit=new URLConnectionHTTPConduit(bus,ei,null); conduit.finalizeConfig(); EndpointReferenceType target=EndpointReferenceUtils.getEndpointReference("http://nowhere.com/bar/foo"); EndpointReferenceType ref=conduit.getTarget(); assertNotNull("unexpected null target",ref); assertEquals("unexpected target",EndpointReferenceUtils.getAddress(ref),EndpointReferenceUtils.getAddress(target)); assertEquals("unexpected address",conduit.getAddress(),"http://nowhere.com/bar/foo"); assertEquals("unexpected on-demand URL",conduit.getURI().getPath(),"/bar/foo"); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
/** * This test verifies the precedence of Authorization Information. * Setting authorization information on the Message takes precedence * over a Basic Auth Supplier with preemptive UserPass, and that * followed by setting it directly on the Conduit. */ @Test public void testAuthPolicyPrecedence() throws Exception { Bus bus=new ExtensionManagerBus(); EndpointInfo ei=new EndpointInfo(); ei.setAddress("http://nowhere.com/bar/foo"); HTTPConduit conduit=new URLConnectionHTTPConduit(bus,ei,null); conduit.finalizeConfig(); conduit.getAuthorization().setUserName("Satan"); conduit.getAuthorization().setPassword("hell"); Message message=getNewMessage(); conduit.prepare(message); Map> headers=CastUtils.cast((Map)message.get(Message.PROTOCOL_HEADERS)); assertNotNull("Authorization Header should exist",headers.get("Authorization")); assertEquals("Unexpected Authorization Token","Basic " + Base64Utility.encode("Satan:hell".getBytes()),headers.get("Authorization").get(0)); conduit.setAuthSupplier(new TestAuthSupplier()); message=getNewMessage(); conduit.prepare(message); headers=CastUtils.cast((Map)message.get(Message.PROTOCOL_HEADERS)); List authorization=headers.get("Authorization"); assertNotNull("Authorization Token must be set",authorization); assertEquals("Wrong Authorization Token","myauth",authorization.get(0)); conduit.setAuthSupplier(null); AuthorizationPolicy authPolicy=new AuthorizationPolicy(); authPolicy.setUserName("Hello"); authPolicy.setPassword("world"); authPolicy.setAuthorizationType("Basic"); message=getNewMessage(); message.put(AuthorizationPolicy.class,authPolicy); conduit.prepare(message); headers=CastUtils.cast((Map)message.get(Message.PROTOCOL_HEADERS)); assertEquals("Unexpected Authorization Token","Basic " + Base64Utility.encode("Hello:world".getBytes()),headers.get("Authorization").get(0)); }

Class: org.apache.cxf.transport.http.HTTPConduitURLConnectionTest

InternalCallVerifier EqualityVerifier 
/** * This test verifies that URL used is overridden by having the * ENDPOINT_ADDRESS set on the Message. */ @Test public void testConnectionURLOverride() throws Exception { Bus bus=new ExtensionManagerBus(); EndpointInfo ei=new EndpointInfo(); ei.setAddress("http://nowhere.null/bar/foo"); HTTPConduit conduit=new URLConnectionHTTPConduit(bus,ei,null); conduit.finalizeConfig(); Message message=getNewMessage(); message.put(Message.ENDPOINT_ADDRESS,"http://somewhere.different/"); conduit.prepare(message); HttpURLConnection con=(HttpURLConnection)message.get("http.connection"); assertEquals("Unexpected URL address",con.getURL().toString(),"http://somewhere.different/"); }

InternalCallVerifier EqualityVerifier 
/** * This test verifies that the "prepare" call places an HttpURLConnection on * the Message and that its URL matches the endpoint. */ @Test public void testConnectionURL() throws Exception { Bus bus=new ExtensionManagerBus(); EndpointInfo ei=new EndpointInfo(); ei.setAddress("http://nowhere.com/bar/foo"); HTTPConduit conduit=new URLConnectionHTTPConduit(bus,ei,null); conduit.finalizeConfig(); Message message=getNewMessage(); conduit.prepare(message); HttpURLConnection con=(HttpURLConnection)message.get("http.connection"); assertEquals("Unexpected URL address",con.getURL().toString(),ei.getAddress()); }

Class: org.apache.cxf.transport.http.HeadersTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void setHeadersTest() throws Exception { String[] headerNames={"Content-Type","authorization","soapAction"}; String[] headerValues={"text/xml","Basic Zm9vOmJhcg==","foo"}; Map> inmap=new HashMap>(); for (int i=0; i < headerNames.length; i++) { inmap.put(headerNames[i],Arrays.asList(headerValues[i])); } HttpServletRequest req=control.createMock(HttpServletRequest.class); EasyMock.expect(req.getHeaderNames()).andReturn(Collections.enumeration(inmap.keySet())); for (int i=0; i < headerNames.length; i++) { EasyMock.expect(req.getHeaders(headerNames[i])).andReturn(Collections.enumeration(inmap.get(headerNames[i]))); } EasyMock.expect(req.getContentType()).andReturn(headerValues[0]).anyTimes(); control.replay(); Message message=new MessageImpl(); message.put(AbstractHTTPDestination.HTTP_REQUEST,req); Headers headers=new Headers(message); headers.copyFromRequest(req); Map> protocolHeaders=CastUtils.cast((Map)message.get(Message.PROTOCOL_HEADERS)); assertTrue("unexpected size",protocolHeaders.size() == headerNames.length); assertEquals("unexpected header",protocolHeaders.get("Content-Type").get(0),headerValues[0]); assertEquals("unexpected header",protocolHeaders.get("content-type").get(0),headerValues[0]); assertEquals("unexpected header",protocolHeaders.get("CONTENT-TYPE").get(0),headerValues[0]); assertEquals("unexpected header",protocolHeaders.get("content-TYPE").get(0),headerValues[0]); assertEquals("unexpected header",protocolHeaders.get("Authorization").get(0),headerValues[1]); assertEquals("unexpected header",protocolHeaders.get("authorization").get(0),headerValues[1]); assertEquals("unexpected header",protocolHeaders.get("AUTHORIZATION").get(0),headerValues[1]); assertEquals("unexpected header",protocolHeaders.get("authoriZATION").get(0),headerValues[1]); assertEquals("unexpected header",protocolHeaders.get("SOAPAction").get(0),headerValues[2]); assertEquals("unexpected header",protocolHeaders.get("soapaction").get(0),headerValues[2]); assertEquals("unexpected header",protocolHeaders.get("SOAPACTION").get(0),headerValues[2]); assertEquals("unexpected header",protocolHeaders.get("soapAction").get(0),headerValues[2]); }

Class: org.apache.cxf.transport.http.asyncclient.AsyncHTTPConduitTest

InternalCallVerifier EqualityVerifier 
@Test public void testInvocationWithTransportId() throws Exception { String address="http://localhost:" + PORT + "/SoapContext/SoapPort"; JaxWsProxyFactoryBean factory=new JaxWsProxyFactoryBean(); factory.setServiceClass(Greeter.class); factory.setAddress(address); factory.setTransportId("http://cxf.apache.org/transports/http/http-client"); Greeter greeter=factory.create(Greeter.class); String response=greeter.greetMe("test"); assertEquals("Get a wrong response","Hello test",response); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testTimeout() throws Exception { updateAddressPort(g,PORT); HTTPConduit c=(HTTPConduit)ClientProxy.getClient(g).getConduit(); c.getClient().setReceiveTimeout(3000); try { assertEquals("Hello " + request,g.greetMeLater(-5000)); fail(); } catch ( Exception ex) { } }

IterativeVerifier InternalCallVerifier EqualityVerifier IgnoredMethod HybridVerifier 
@Test @Ignore("peformance test") public void testCalls() throws Exception { updateAddressPort(g,PORT); for (int x=0; x < 10000; x++) { String value=g.greetMe(request); assertEquals("Hello " + request,value); } long start=System.currentTimeMillis(); for (int x=0; x < 10000; x++) { g.greetMe(request); } long end=System.currentTimeMillis(); System.out.println("Total: " + (end - start)); }

InternalCallVerifier EqualityVerifier 
@Test public void testInovationWithHCAddress() throws Exception { String address="hc://http://localhost:" + PORT + "/SoapContext/SoapPort"; JaxWsProxyFactoryBean factory=new JaxWsProxyFactoryBean(); factory.setServiceClass(Greeter.class); factory.setAddress(address); Greeter greeter=factory.create(Greeter.class); String response=greeter.greetMe("test"); assertEquals("Get a wrong response","Hello test",response); }

InternalCallVerifier EqualityVerifier 
@Test public void testCall() throws Exception { updateAddressPort(g,PORT); assertEquals("Hello " + request,g.greetMe(request)); HTTPConduit c=(HTTPConduit)ClientProxy.getClient(g).getConduit(); HTTPClientPolicy cp=new HTTPClientPolicy(); cp.setAllowChunking(false); c.setClient(cp); assertEquals("Hello " + request,g.greetMe(request)); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testCallAsync() throws Exception { updateAddressPort(g,PORT); GreetMeResponse resp=(GreetMeResponse)g.greetMeAsync(request,new AsyncHandler(){ public void handleResponse( Response res){ try { res.get().getResponseType(); } catch ( InterruptedException e) { e.printStackTrace(); } catch ( ExecutionException e) { e.printStackTrace(); } } } ).get(); assertEquals("Hello " + request,resp.getResponseType()); g.greetMeLaterAsync(1000,new AsyncHandler(){ public void handleResponse( Response res){ } } ).get(); }

Class: org.apache.cxf.transport.http.auth.DigestAuthSupplierTest

EqualityVerifier 
/** * Tests that parseHeader correctly parses parameters that contain == * @throws Exception */ @Test public void testCXF2370() throws Exception { String origNonce="MTI0ODg3OTc5NzE2OTplZGUyYTg0Yzk2NTFkY2YyNjc1Y2JjZjU2MTUzZmQyYw=="; String fullHeader="Digest realm=\"MyCompany realm.\", qop=\"auth\"," + "nonce=\"" + origNonce + "\""; Map map=new HttpAuthHeader(fullHeader).getParams(); assertEquals(origNonce,map.get("nonce")); assertEquals("auth",map.get("qop")); assertEquals("MyCompany realm.",map.get("realm")); }

InternalCallVerifier EqualityVerifier 
@Test public void testEncode() throws Exception { String origNonce="MTI0ODg3OTc5NzE2OTplZGUyYTg0Yzk2NTFkY2YyNjc1Y2JjZjU2MTUzZmQyYw=="; String fullHeader="Digest realm=\"MyCompany realm.\", qop=\"auth\"," + "nonce=\"" + origNonce + "\""; DigestAuthSupplier authSupplier=new DigestAuthSupplier(){ @Override public String createCnonce() throws UnsupportedEncodingException { return "27db039b76362f3d55da10652baee38c"; } } ; IMocksControl control=EasyMock.createControl(); AuthorizationPolicy authorizationPolicy=new AuthorizationPolicy(); authorizationPolicy.setUserName("testUser"); authorizationPolicy.setPassword("testPassword"); URI uri=new URI("http://myserver"); Message message=new MessageImpl(); control.replay(); String authToken=authSupplier.getAuthorization(authorizationPolicy,uri,message,fullHeader); HttpAuthHeader authHeader=new HttpAuthHeader(authToken); assertEquals("Digest",authHeader.getAuthType()); Map params=authHeader.getParams(); Map expectedParams=new HashMap(); expectedParams.put("response","28e616b6868f60aaf9b19bb5b172f076"); expectedParams.put("cnonce","27db039b76362f3d55da10652baee38c"); expectedParams.put("username","testUser"); expectedParams.put("nc","00000001"); expectedParams.put("nonce","MTI0ODg3OTc5NzE2OTplZGUyYTg0Yzk2NTFkY2YyNjc1Y2JjZjU2MTUzZmQyYw=="); expectedParams.put("realm","MyCompany realm."); expectedParams.put("qop","auth"); expectedParams.put("uri",""); expectedParams.put("algorithm","MD5"); assertEquals(expectedParams,params); control.verify(); }

Class: org.apache.cxf.transport.http.auth.HttpAuthHeaderTest

InternalCallVerifier EqualityVerifier 
@Test public void testParse(){ HttpAuthHeader authHeader=new HttpAuthHeader("Digest nonce=\"TUzZmQyYw==\", username=\"testUser\""); assertEquals("Digest",authHeader.getAuthType()); Map params=authHeader.getParams(); Map expectedParams=new HashMap(); expectedParams.put("username","testUser"); expectedParams.put("nonce","TUzZmQyYw=="); assertEquals(expectedParams,params); }

Class: org.apache.cxf.transport.http.netty.client.integration.NettyClientTest

InternalCallVerifier EqualityVerifier 
@Test public void testInovationWithNettyAddress() throws Exception { String address="netty://http://localhost:" + PORT + "/SoapContext/SoapPort"; JaxWsProxyFactoryBean factory=new JaxWsProxyFactoryBean(); factory.setServiceClass(Greeter.class); factory.setAddress(address); Greeter greeter=factory.create(Greeter.class); String response=greeter.greetMe("test"); assertEquals("Get a wrong response","Hello test",response); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testCallAsync() throws Exception { updateAddressPort(g,PORT); GreetMeResponse resp=(GreetMeResponse)g.greetMeAsync("asyncTest",new AsyncHandler(){ public void handleResponse( Response res){ try { res.get().getResponseType(); } catch ( InterruptedException e) { e.printStackTrace(); } catch ( ExecutionException e) { e.printStackTrace(); } } } ).get(); assertEquals("Hello asyncTest",resp.getResponseType()); MyLaterResponseHandler handler=new MyLaterResponseHandler(); g.greetMeLaterAsync(1000,handler).get(); assertEquals("Hello, finally!",handler.getResponse().getResponseType()); }

InternalCallVerifier EqualityVerifier 
@Test public void testInvocationWithTransportId() throws Exception { String address="http://localhost:" + PORT + "/SoapContext/SoapPort"; JaxWsProxyFactoryBean factory=new JaxWsProxyFactoryBean(); factory.setServiceClass(Greeter.class); factory.setAddress(address); factory.setTransportId("http://cxf.apache.org/transports/http/netty/client"); Greeter greeter=factory.create(Greeter.class); String response=greeter.greetMe("test"); assertEquals("Get a wrong response","Hello test",response); }

InternalCallVerifier EqualityVerifier 
@Test public void testInvocation() throws Exception { updateAddressPort(g,PORT); String response=g.greetMe("test"); assertEquals("Get a wrong response","Hello test",response); }

Class: org.apache.cxf.transport.http.netty.client.integration.SSLNettyClientTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testInvocation() throws Exception { setupTLS(g); setAddress(g,address); String response=g.greetMe("test"); assertEquals("Get a wrong response","Hello test",response); GreetMeResponse resp=(GreetMeResponse)g.greetMeAsync("asyncTest",new AsyncHandler(){ public void handleResponse( Response res){ try { res.get().getResponseType(); } catch ( InterruptedException e) { e.printStackTrace(); } catch ( ExecutionException e) { e.printStackTrace(); } } } ).get(); assertEquals("Hello asyncTest",resp.getResponseType()); MyLaterResponseHandler handler=new MyLaterResponseHandler(); g.greetMeLaterAsync(1000,handler).get(); assertEquals("Hello, finally!",handler.getResponse().getResponseType()); }

Class: org.apache.cxf.transport.http.netty.server.NettyHttpDestinationTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetAnonBackChannel() throws Exception { destination=setUpDestination(false,false); setUpDoService(false); destination.doService(request,response); setUpInMessage(); Conduit backChannel=destination.getBackChannel(inMessage); assertNotNull("expected back channel",backChannel); assertEquals("unexpected target",EndpointReferenceUtils.ANONYMOUS_ADDRESS,backChannel.getTarget().getAddress().getValue()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testMultiplexGetIdForAddress() throws Exception { destination=setUpDestination(); destination.setMultiplexWithAddress(true); final String id="ID3"; EndpointReferenceType refWithId=destination.getAddressWithId(id); String pathInfo=EndpointReferenceUtils.getAddress(refWithId); Map context=new HashMap(); assertNull("fails with no context",destination.getId(context)); context.put(Message.PATH_INFO,pathInfo); String result=destination.getId(context); assertNotNull(result); assertEquals("match our id",result,id); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetAddress() throws Exception { destination=setUpDestination(); EndpointReferenceType ref=destination.getAddress(); assertNotNull("unexpected null address",ref); assertEquals("unexpected address",EndpointReferenceUtils.getAddress(ref),StringUtils.addDefaultPortIfMissing(EndpointReferenceUtils.getAddress(address))); assertEquals("unexpected service name local part",EndpointReferenceUtils.getServiceName(ref,bus).getLocalPart(),"Service"); assertEquals("unexpected portName",EndpointReferenceUtils.getPortName(ref),"Port"); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testMultiplexGetAddressWithId() throws Exception { destination=setUpDestination(); final String id="ID2"; EndpointReferenceType refWithId=destination.getAddressWithId(id); assertNotNull(refWithId); assertNotNull(refWithId.getReferenceParameters()); assertNotNull(refWithId.getReferenceParameters().getAny()); assertTrue("it is an element",refWithId.getReferenceParameters().getAny().get(0) instanceof JAXBElement); JAXBElement el=(JAXBElement)refWithId.getReferenceParameters().getAny().get(0); assertEquals("match our id",el.getValue(),id); }

InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testGetMultiple() throws Exception { transportFactory=new HTTPTransportFactory(); bus=BusFactory.getDefaultBus(); ServiceInfo serviceInfo=new ServiceInfo(); serviceInfo.setName(new QName("bla","Service")); EndpointInfo ei=new EndpointInfo(serviceInfo,""); ei.setName(new QName("bla","Port")); ei.setAddress("http://foo"); Destination d1=transportFactory.getDestination(ei,bus); Destination d2=transportFactory.getDestination(ei,bus); assertEquals(d1,d2); d2.shutdown(); Destination d3=transportFactory.getDestination(ei,bus); assertNotSame(d1,d3); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testMultiplexGetId() throws Exception { destination=setUpDestination(); final String id="ID3"; EndpointReferenceType refWithId=destination.getAddressWithId(id); Map context=new HashMap(); assertNull("fails with no context",destination.getId(context)); AddressingProperties maps=EasyMock.createMock(AddressingProperties.class); maps.getToEndpointReference(); EasyMock.expectLastCall().andReturn(refWithId); EasyMock.replay(maps); context.put(JAXWSAConstants.ADDRESSING_PROPERTIES_INBOUND,maps); String result=destination.getId(context); assertNotNull(result); assertEquals("match our id",result,id); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDoServiceWithHttpGET() throws Exception { destination=setUpDestination(false,false); setUpDoService(false,false,false,"GET","?customerId=abc&cutomerAdd=def",200); destination.doService(request,response); assertNotNull("unexpected null message",inMessage); assertEquals("unexpected method",inMessage.get(Message.HTTP_REQUEST_METHOD),"GET"); assertEquals("unexpected path",inMessage.get(Message.PATH_INFO),"/bar/foo"); assertEquals("unexpected query",inMessage.get(Message.QUERY_STRING),"?customerId=abc&cutomerAdd=def"); }

InternalCallVerifier EqualityVerifier 
@Test public void testServerPolicyInServiceModel() throws Exception { policy=new HTTPServerPolicy(); address=getEPR("bar/foo"); bus=new ExtensionManagerBus(); transportFactory=new HTTPTransportFactory(); ServiceInfo serviceInfo=new ServiceInfo(); serviceInfo.setName(new QName("bla","Service")); endpointInfo=new EndpointInfo(serviceInfo,""); endpointInfo.setName(new QName("bla","Port")); endpointInfo.addExtensor(policy); engine=EasyMock.createMock(NettyHttpServerEngine.class); EasyMock.replay(); endpointInfo.setAddress(NOWHERE + "bar/foo"); NettyHttpDestination dest=new EasyMockJettyHTTPDestination(bus,transportFactory.getRegistry(),endpointInfo,null,engine); assertEquals(policy,dest.getServer()); }

Class: org.apache.cxf.transport.http.netty.server.NettyHttpServerEngineTest

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testNettyHttpHandler() throws Exception { String urlStr1="http://localhost:" + PORT3 + "/hello/test"; String urlStr2="http://localhost:" + PORT3 + "/hello/test2"; NettyHttpServerEngine engine=factory.createNettyHttpServerEngine(PORT3,"http"); NettyHttpTestHandler handler1=new NettyHttpTestHandler("test",false); NettyHttpTestHandler handler2=new NettyHttpTestHandler("test2",false); engine.addServant(new URL(urlStr1),handler1); engine.addServant(new URL(urlStr2),handler2); String response=null; try { response=getResponse(urlStr1 + "/test"); } catch ( Exception ex) { fail("Can't get the reponse from the server " + ex); } assertEquals("the netty http handler did not take effect",response,"test"); try { response=getResponse(urlStr2 + "/test"); } catch ( Exception ex) { fail("Can't get the reponse from the server " + ex); } assertEquals("the netty http handler did not take effect",response,"test2"); NettyHttpServerEngineFactory.destroyForPort(PORT3); }

APIUtilityVerifier UtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testaddServants() throws Exception { String urlStr="http://localhost:" + PORT1 + "/hello/test"; String urlStr2="http://localhost:" + PORT1 + "/hello233/test"; NettyHttpServerEngine engine=factory.createNettyHttpServerEngine(PORT1,"http"); NettyHttpTestHandler handler1=new NettyHttpTestHandler("string1",true); NettyHttpTestHandler handler2=new NettyHttpTestHandler("string2",true); engine.addServant(new URL(urlStr),handler1); String response=null; response=getResponse(urlStr); assertEquals("The netty http handler did not take effect",response,"string1"); try { engine.addServant(new URL(urlStr),handler2); fail("We don't support to publish the two service at the same context path"); } catch ( Exception ex) { assertTrue("Get a wrong exception message",ex.getMessage().indexOf("hello/test") > 0); } engine.addServant(new URL(urlStr2),handler2); engine.removeServant(new URL(urlStr)); response=getResponse(urlStr2); assertEquals("The netty http handler did not take effect",response,"string2"); engine.shutdown(); NettyHttpServerEngineFactory.destroyForPort(PORT1); }

Class: org.apache.cxf.transport.http.netty.server.integration.NettyServerTest

InternalCallVerifier EqualityVerifier 
@Test public void testInvocation() throws Exception { updateAddressPort(g,PORT); String response=g.greetMe("test"); assertEquals("Get a wrong response","Hello test",response); }

Class: org.apache.cxf.transport.http.netty.server.integration.SSLNettyServerTest

InternalCallVerifier EqualityVerifier 
@Test public void testInvocation() throws Exception { setupTLS(g); setAddress(g,address); String response=g.greetMe("test"); assertEquals("Get a wrong response","Hello test",response); }

Class: org.apache.cxf.transport.http.policy.ClientPolicyCalculatorTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testIntersectClientPolicies(){ ClientPolicyCalculator calc=new ClientPolicyCalculator(); HTTPClientPolicy p1=new HTTPClientPolicy(); HTTPClientPolicy p2=new HTTPClientPolicy(); HTTPClientPolicy p=null; p1.setBrowserType("browser"); p=calc.intersect(p1,p2); assertEquals("browser",p.getBrowserType()); p1.setBrowserType(null); p1.setConnectionTimeout(10000L); p=calc.intersect(p1,p2); assertEquals(10000L,p.getConnectionTimeout()); p1.setAllowChunking(false); p2.setAllowChunking(false); p=calc.intersect(p1,p2); assertTrue(!p.isAllowChunking()); }

InternalCallVerifier EqualityVerifier 
@Test public void testLongTimeouts(){ ClientPolicyCalculator calc=new ClientPolicyCalculator(); HTTPClientPolicy p1=new HTTPClientPolicy(); HTTPClientPolicy p2=new HTTPClientPolicy(); p2.setReceiveTimeout(120000); p2.setConnectionTimeout(60000); HTTPClientPolicy p=calc.intersect(p1,p2); assertEquals(120000,p.getReceiveTimeout()); assertEquals(60000,p.getConnectionTimeout()); p1=new HTTPClientPolicy(); p2=new HTTPClientPolicy(); p1.setReceiveTimeout(120000); p1.setConnectionTimeout(60000); p=calc.intersect(p1,p2); assertEquals(120000,p.getReceiveTimeout()); assertEquals(60000,p.getConnectionTimeout()); p2.setReceiveTimeout(50000); p2.setConnectionTimeout(20000); p=calc.intersect(p1,p2); assertEquals(120000,p.getReceiveTimeout()); assertEquals(60000,p.getConnectionTimeout()); p=calc.intersect(p2,p1); assertEquals(50000,p.getReceiveTimeout()); assertEquals(20000,p.getConnectionTimeout()); }

Class: org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilderTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testBuildAssertion() throws Exception { HTTPClientAssertionBuilder ab=new HTTPClientAssertionBuilder(); Assertion a=ab.buildAssertion(); assertTrue(a instanceof JaxbAssertion); assertTrue(a instanceof HTTPClientAssertionBuilder.HTTPClientPolicyAssertion); assertEquals(new ClientPolicyCalculator().getDataClassName(),a.getName()); assertTrue(!a.isOptional()); }

Class: org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilderTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testBuildAssertion() throws Exception { HTTPServerAssertionBuilder ab=new HTTPServerAssertionBuilder(); Assertion a=ab.buildAssertion(); assertTrue(a instanceof JaxbAssertion); assertTrue(a instanceof HTTPServerAssertionBuilder.HTTPServerPolicyAssertion); assertEquals(new ServerPolicyCalculator().getDataClassName(),a.getName()); assertTrue(!a.isOptional()); }

Class: org.apache.cxf.transport.http.policy.ServerPolicyCalculatorTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testIntersectServerPolicies(){ ServerPolicyCalculator spc=new ServerPolicyCalculator(); HTTPServerPolicy p1=new HTTPServerPolicy(); HTTPServerPolicy p2=new HTTPServerPolicy(); HTTPServerPolicy p=null; p1.setServerType("server"); p=spc.intersect(p1,p2); assertEquals("server",p.getServerType()); p1.setServerType(null); p1.setReceiveTimeout(10000L); p=spc.intersect(p1,p2); assertEquals(10000L,p.getReceiveTimeout()); p1.setSuppressClientSendErrors(true); p2.setSuppressClientSendErrors(true); p=spc.intersect(p1,p2); assertTrue(p.isSuppressClientSendErrors()); }

Class: org.apache.cxf.transport.http_jaxws_spi.JAXWSHttpSpiDestinationTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCtor() throws Exception { control.replay(); JAXWSHttpSpiDestination destination=new JAXWSHttpSpiDestination(bus,new DestinationRegistryImpl(),endpoint); assertNull(destination.getMessageObserver()); assertNotNull(destination.getAddress()); assertNotNull(destination.getAddress().getAddress()); assertEquals(ADDRESS,destination.getAddress().getAddress().getValue()); }

Class: org.apache.cxf.transport.http_jetty.JettyHTTPDestinationTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetAddress() throws Exception { destination=setUpDestination(); EndpointReferenceType ref=destination.getAddress(); assertNotNull("unexpected null address",ref); assertEquals("unexpected address",EndpointReferenceUtils.getAddress(ref),StringUtils.addDefaultPortIfMissing(EndpointReferenceUtils.getAddress(address))); assertEquals("unexpected service name local part",EndpointReferenceUtils.getServiceName(ref,bus).getLocalPart(),"Service"); assertEquals("unexpected portName",EndpointReferenceUtils.getPortName(ref),"Port"); }

InternalCallVerifier EqualityVerifier 
@Test public void testServerPolicyInServiceModel() throws Exception { policy=new HTTPServerPolicy(); address=getEPR("bar/foo"); bus=BusFactory.getDefaultBus(true); transportFactory=new HTTPTransportFactory(); ServiceInfo serviceInfo=new ServiceInfo(); serviceInfo.setName(new QName("bla","Service")); endpointInfo=new EndpointInfo(serviceInfo,""); endpointInfo.setName(new QName("bla","Port")); endpointInfo.addExtensor(policy); engine=EasyMock.createMock(JettyHTTPServerEngine.class); EasyMock.replay(); endpointInfo.setAddress(NOWHERE + "bar/foo"); JettyHTTPDestination dest=new EasyMockJettyHTTPDestination(bus,transportFactory.getRegistry(),endpointInfo,null,engine); assertEquals(policy,dest.getServer()); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testMultiplexGetAddressWithId() throws Exception { destination=setUpDestination(); final String id="ID2"; EndpointReferenceType refWithId=destination.getAddressWithId(id); assertNotNull(refWithId); assertNotNull(refWithId.getReferenceParameters()); assertNotNull(refWithId.getReferenceParameters().getAny()); assertTrue("it is an element",refWithId.getReferenceParameters().getAny().get(0) instanceof JAXBElement); JAXBElement el=(JAXBElement)refWithId.getReferenceParameters().getAny().get(0); assertEquals("match our id",el.getValue(),id); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testMultiplexGetId() throws Exception { destination=setUpDestination(); final String id="ID3"; EndpointReferenceType refWithId=destination.getAddressWithId(id); Map context=new HashMap(); assertNull("fails with no context",destination.getId(context)); AddressingProperties maps=EasyMock.createMock(AddressingProperties.class); maps.getToEndpointReference(); EasyMock.expectLastCall().andReturn(refWithId); EasyMock.replay(maps); context.put(JAXWSAConstants.ADDRESSING_PROPERTIES_INBOUND,maps); String result=destination.getId(context); assertNotNull(result); assertEquals("match our id",result,id); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDoServiceWithHttpGET() throws Exception { destination=setUpDestination(false,false); setUpDoService(false,false,false,"GET","?customerId=abc&cutomerAdd=def",200); destination.doService(request,response); assertNotNull("unexpected null message",inMessage); assertEquals("unexpected method",inMessage.get(Message.HTTP_REQUEST_METHOD),"GET"); assertEquals("unexpected path",inMessage.get(Message.PATH_INFO),"/bar/foo"); assertEquals("unexpected query",inMessage.get(Message.QUERY_STRING),"?customerId=abc&cutomerAdd=def"); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetAnonBackChannel() throws Exception { destination=setUpDestination(false,false); setUpDoService(false); destination.doService(request,response); setUpInMessage(); Conduit backChannel=destination.getBackChannel(inMessage); assertNotNull("expected back channel",backChannel); assertEquals("unexpected target",EndpointReferenceUtils.ANONYMOUS_ADDRESS,backChannel.getTarget().getAddress().getValue()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testMultiplexGetIdForAddress() throws Exception { destination=setUpDestination(); destination.setMultiplexWithAddress(true); final String id="ID3"; EndpointReferenceType refWithId=destination.getAddressWithId(id); String pathInfo=EndpointReferenceUtils.getAddress(refWithId); Map context=new HashMap(); assertNull("fails with no context",destination.getId(context)); context.put(Message.PATH_INFO,pathInfo); String result=destination.getId(context); assertNotNull(result); assertEquals("match our id",result,id); }

InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testGetMultiple() throws Exception { bus=BusFactory.getDefaultBus(true); transportFactory=new HTTPTransportFactory(); ServiceInfo serviceInfo=new ServiceInfo(); serviceInfo.setName(new QName("bla","Service")); EndpointInfo ei=new EndpointInfo(serviceInfo,""); ei.setName(new QName("bla","Port")); ei.setAddress("http://foo"); Destination d1=transportFactory.getDestination(ei,bus); Destination d2=transportFactory.getDestination(ei,bus); assertEquals(d1,d2); d2.shutdown(); Destination d3=transportFactory.getDestination(ei,bus); assertNotSame(d1,d3); }

Class: org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactoryTest

UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
/** * This test makes sure that with a * that the bus is configured with the rightly configured Jetty * HTTP Server Engine Factory. Port 1234 should have be configured * for TLS. */ @Test public void testMakeSureTransportFactoryHasEngineFactoryConfigured() throws Exception { URL config=getClass().getResource("server-engine-factory.xml"); bus=new SpringBusFactory().createBus(config,true); JettyHTTPServerEngineFactory factory=bus.getExtension(JettyHTTPServerEngineFactory.class); assertNotNull("EngineFactory is not configured.",factory); JettyHTTPServerEngine engine=null; engine=factory.createJettyHTTPServerEngine(1234,"https"); assertNotNull("Engine is not available.",engine); assertEquals(1234,engine.getPort()); assertEquals("Not https","https",engine.getProtocol()); try { engine=factory.createJettyHTTPServerEngine(1234,"http"); fail("The engine's protocol should be https"); } catch ( Exception e) { } }

Class: org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineTest

APIUtilityVerifier UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetContextHandler() throws Exception { String urlStr="http://localhost:" + PORT1 + "/hello/test"; JettyHTTPServerEngine engine=factory.createJettyHTTPServerEngine(PORT1,"http"); ContextHandler contextHandler=engine.getContextHandler(new URL(urlStr)); assertNull(contextHandler); JettyHTTPTestHandler handler1=new JettyHTTPTestHandler("string1",true); JettyHTTPTestHandler handler2=new JettyHTTPTestHandler("string2",true); engine.addServant(new URL(urlStr),handler1); contextHandler=engine.getContextHandler(new URL(urlStr)); contextHandler.stop(); contextHandler.setHandler(handler2); contextHandler.start(); String response=null; try { response=getResponse(urlStr); } catch ( Exception ex) { fail("Can't get the reponse from the server " + ex); } assertEquals("the jetty http handler did not take effect",response,"string2"); JettyHTTPServerEngineFactory.destroyForPort(PORT1); }

APIUtilityVerifier UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testSetHandlers() throws Exception { URL url=new URL("http://localhost:" + PORT2 + "/hello/test"); JettyHTTPTestHandler handler1=new JettyHTTPTestHandler("string1",true); JettyHTTPTestHandler handler2=new JettyHTTPTestHandler("string2",true); JettyHTTPServerEngine engine=new JettyHTTPServerEngine(); engine.setPort(PORT2); List handlers=new ArrayList(); handlers.add(handler1); engine.setHandlers(handlers); engine.finalizeConfig(); engine.addServant(url,handler2); String response=null; try { response=getResponse(url.toString()); assertEquals("the jetty http handler1 did not take effect",response,"string1string2"); } catch ( Exception ex) { fail("Can't get the reponse from the server " + ex); } engine.stop(); JettyHTTPServerEngineFactory.destroyForPort(PORT2); }

UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testJettyHTTPHandler() throws Exception { String urlStr1="http://localhost:" + PORT3 + "/hello/test1"; String urlStr2="http://localhost:" + PORT3 + "/hello/test2"; JettyHTTPServerEngine engine=factory.createJettyHTTPServerEngine(PORT3,"http"); ContextHandler contextHandler=engine.getContextHandler(new URL(urlStr1)); assertNull(contextHandler); JettyHTTPHandler handler1=new JettyHTTPTestHandler("test",false); JettyHTTPHandler handler2=new JettyHTTPTestHandler("test2",false); engine.addServant(new URL(urlStr1),handler1); contextHandler=engine.getContextHandler(new URL(urlStr1)); engine.addServant(new URL(urlStr2),handler2); contextHandler=engine.getContextHandler(new URL(urlStr2)); String response=null; try { response=getResponse(urlStr1 + "/test"); } catch ( Exception ex) { fail("Can't get the reponse from the server " + ex); } assertEquals("the jetty http handler did not take effect",response,"test"); try { response=getResponse(urlStr2 + "/test"); } catch ( Exception ex) { fail("Can't get the reponse from the server " + ex); } assertEquals("the jetty http handler did not take effect",response,"test2"); JettyHTTPServerEngineFactory.destroyForPort(PORT3); }

APIUtilityVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testaddServants() throws Exception { String urlStr="http://localhost:" + PORT1 + "/hello/test"; String urlStr2="http://localhost:" + PORT1 + "/hello233/test"; JettyHTTPServerEngine engine=factory.createJettyHTTPServerEngine(PORT1,"http"); engine.setMaxIdleTime(30000); engine.addServant(new URL(urlStr),new JettyHTTPTestHandler("string1",true)); assertEquals("Get the wrong maxIdleTime.",30000,getMaxIdle(engine.getConnector())); String response=null; response=getResponse(urlStr); assertEquals("The jetty http handler did not take effect",response,"string1"); try { engine.addServant(new URL(urlStr),new JettyHTTPTestHandler("string2",true)); fail("We don't support to publish the two service at the same context path"); } catch ( Exception ex) { assertTrue("Get a wrong exception message",ex.getMessage().indexOf("hello/test") > 0); } try { engine.addServant(new URL(urlStr + "/test"),new JettyHTTPTestHandler("string2",true)); fail("We don't support to publish the two service at the same context path"); } catch ( Exception ex) { assertTrue("Get a wrong exception message",ex.getMessage().indexOf("hello/test/test") > 0); } try { engine.addServant(new URL("http://localhost:" + PORT1 + "/hello"),new JettyHTTPTestHandler("string2",true)); fail("We don't support to publish the two service at the same context path"); } catch ( Exception ex) { assertTrue("Get a wrong exception message",ex.getMessage().indexOf("hello") > 0); } System.setProperty("org.apache.cxf.transports.http_jetty.DontCheckUrl","true"); engine.addServant(new URL(urlStr + "/test"),new JettyHTTPTestHandler("string2",true)); System.clearProperty("org.apache.cxf.transports.http_jetty.DontCheckUrl"); engine.addServant(new URL(urlStr2),new JettyHTTPTestHandler("string2",true)); Set s=CastUtils.cast(ManagementFactory.getPlatformMBeanServer().queryNames(new ObjectName("org.eclipse.jetty.server:type=server,*"),null)); assertEquals("Could not find 1 Jetty Server: " + s,1,s.size()); engine.removeServant(new URL(urlStr)); engine.shutdown(); response=getResponse(urlStr2); assertEquals("The jetty http handler did not take effect",response,"string2"); JettyHTTPServerEngineFactory.destroyForPort(PORT1); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testHttpAndHttps() throws Exception { JettyHTTPServerEngine engine=factory.createJettyHTTPServerEngine(PORT1,"http"); assertTrue("Protocol must be http","http".equals(engine.getProtocol())); engine=new JettyHTTPServerEngine(); engine.setPort(PORT2); engine.setMaxIdleTime(30000); engine.setTlsServerParameters(new TLSServerParameters()); engine.finalizeConfig(); List list=new ArrayList(); list.add(engine); factory.setEnginesList(list); engine=factory.createJettyHTTPServerEngine(PORT2,"https"); JettyHTTPTestHandler handler1=new JettyHTTPTestHandler("string1",true); engine.addServant(new URL("https://localhost:" + PORT2 + "/test"),handler1); assertTrue("Protocol must be https","https".equals(engine.getProtocol())); assertEquals("Get the wrong maxIdleTime.",30000,getMaxIdle(engine.getConnector())); factory.setTLSServerParametersForPort(PORT1,new TLSServerParameters()); engine=factory.createJettyHTTPServerEngine(PORT1,"https"); assertTrue("Protocol must be https","https".equals(engine.getProtocol())); factory.setTLSServerParametersForPort(PORT3,new TLSServerParameters()); engine=factory.createJettyHTTPServerEngine(PORT3,"https"); assertTrue("Protocol must be https","https".equals(engine.getProtocol())); JettyHTTPServerEngineFactory.destroyForPort(PORT1); JettyHTTPServerEngineFactory.destroyForPort(PORT2); JettyHTTPServerEngineFactory.destroyForPort(PORT3); }

EqualityVerifier 
/** * Test that multiple JettyHTTPServerEngine instances can be used simultaneously * without having name collisions. */ @Test public void testJmxSupport() throws Exception { String urlStr="http://localhost:" + PORT1 + "/hello/test"; String urlStr2="http://localhost:" + PORT2 + "/hello/test"; JettyHTTPServerEngine engine=factory.createJettyHTTPServerEngine(PORT1,"http"); JettyHTTPServerEngine engine2=factory.createJettyHTTPServerEngine(PORT2,"http"); JettyHTTPTestHandler handler1=new JettyHTTPTestHandler("string1",true); JettyHTTPTestHandler handler2=new JettyHTTPTestHandler("string2",true); engine.addServant(new URL(urlStr),handler1); Set s=CastUtils.cast(ManagementFactory.getPlatformMBeanServer().queryNames(new ObjectName("org.eclipse.jetty.server:type=server,*"),null)); assertEquals("Could not find 1 Jetty Server: " + s,1,s.size()); engine2.addServant(new URL(urlStr2),handler2); s=CastUtils.cast(ManagementFactory.getPlatformMBeanServer().queryNames(new ObjectName("org.eclipse.jetty.server:type=server,*"),null)); assertEquals("Could not find 2 Jetty Server: " + s,2,s.size()); engine.removeServant(new URL(urlStr)); engine2.removeServant(new URL(urlStr2)); engine.shutdown(); s=CastUtils.cast(ManagementFactory.getPlatformMBeanServer().queryNames(new ObjectName("org.eclipse.jetty.server:type=server,*"),null)); assertEquals("Could not find 2 Jetty Server: " + s,1,s.size()); engine2.shutdown(); s=CastUtils.cast(ManagementFactory.getPlatformMBeanServer().queryNames(new ObjectName("org.eclipse.jetty.server:type=server,*"),null)); assertEquals("Could not find 0 Jetty Server: " + s,0,s.size()); JettyHTTPServerEngineFactory.destroyForPort(PORT1); JettyHTTPServerEngineFactory.destroyForPort(PORT2); }

Class: org.apache.cxf.transport.http_jetty.spring.BeanDefinitionParsersTest

InternalCallVerifier EqualityVerifier 
@Test public void testDest() throws Exception { BeanDefinitionBuilder bd=BeanDefinitionBuilder.childBeanDefinition("child"); HttpDestinationBeanDefinitionParser parser=new HttpDestinationBeanDefinitionParser(); Document d=StaxUtils.read(getClass().getResourceAsStream("destination.xml")); parser.doParse(d.getDocumentElement(),null,bd); PropertyValue[] pvs=bd.getRawBeanDefinition().getPropertyValues().getPropertyValues(); assertEquals(2,pvs.length); assertEquals("foobar",((HTTPServerPolicy)pvs[0].getValue()).getContentEncoding()); assertEquals("exact",pvs[1].getValue()); }

InternalCallVerifier EqualityVerifier 
@Test public void testConduit() throws Exception { BeanDefinitionBuilder bd=BeanDefinitionBuilder.childBeanDefinition("child"); HttpConduitBeanDefinitionParser parser=new HttpConduitBeanDefinitionParser(); Document d=StaxUtils.read(getClass().getResourceAsStream("conduit.xml")); parser.doParse(d.getDocumentElement(),null,bd); PropertyValue[] pvs=bd.getRawBeanDefinition().getPropertyValues().getPropertyValues(); assertEquals(1,pvs.length); assertEquals(97,((HTTPClientPolicy)pvs[0].getValue()).getConnectionTimeout(),0); }

Class: org.apache.cxf.transport.https.httpclient.DefaultHostnameVerifierTest

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testExtractCN() throws Exception { Assert.assertEquals("blah",DefaultHostnameVerifier.extractCN("cn=blah, ou=blah, o=blah")); Assert.assertEquals("blah",DefaultHostnameVerifier.extractCN("cn=blah, cn=yada, cn=booh")); Assert.assertEquals("blah",DefaultHostnameVerifier.extractCN("c = pampa , cn = blah , ou = blah , o = blah")); Assert.assertEquals("blah",DefaultHostnameVerifier.extractCN("cn=\"blah\", ou=blah, o=blah")); Assert.assertEquals("blah blah",DefaultHostnameVerifier.extractCN("cn=\"blah blah\", ou=blah, o=blah")); Assert.assertEquals("blah, blah",DefaultHostnameVerifier.extractCN("cn=\"blah, blah\", ou=blah, o=blah")); Assert.assertEquals("blah, blah",DefaultHostnameVerifier.extractCN("cn=blah\\, blah, ou=blah, o=blah")); Assert.assertEquals("blah",DefaultHostnameVerifier.extractCN("c = cn=uuh, cn=blah, ou=blah, o=blah")); try { DefaultHostnameVerifier.extractCN("blah,blah"); Assert.fail("SSLException expected"); } catch ( SSLException expected) { } try { DefaultHostnameVerifier.extractCN("cn,o=blah"); Assert.fail("SSLException expected"); } catch ( SSLException expected) { } }

APIUtilityVerifier UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testSubjectAlt() throws Exception { final CertificateFactory cf=CertificateFactory.getInstance("X.509"); final InputStream in=new ByteArrayInputStream(CertificatesToPlayWith.X509_MULTIPLE_SUBJECT_ALT); final X509Certificate x509=(X509Certificate)cf.generateCertificate(in); Assert.assertEquals("CN=localhost, OU=Unknown, O=Unknown, L=Unknown, ST=Unknown, C=CH",x509.getSubjectDN().getName()); impl.verify("localhost.localdomain",x509); impl.verify("127.0.0.1",x509); try { impl.verify("localhost",x509); Assert.fail("SSLException should have been thrown"); } catch ( final SSLException ex) { } try { impl.verify("local.host",x509); Assert.fail("SSLException should have been thrown"); } catch ( final SSLException ex) { } try { impl.verify("127.0.0.2",x509); Assert.fail("SSLException should have been thrown"); } catch ( final SSLException ex) { } }

Class: org.apache.cxf.transport.jms.JMSConduitTest

APIUtilityVerifier EqualityVerifier 
@Test public void testGetConfiguration() throws Exception { EndpointInfo ei=setupServiceInfo("http://cxf.apache.org/hello_world_jms",WSDL,"HelloWorldQueueBinMsgService","HelloWorldQueueBinMsgPort"); JMSConduit conduit=setupJMSConduit(ei); assertEquals("Can't get the right ClientReceiveTimeout",500L,conduit.getJmsConfig().getReceiveTimeout().longValue()); conduit.close(); }

Class: org.apache.cxf.transport.jms.JMSConfigFactoryTest

EqualityVerifier 
@Test public void testTransactionManagerFromJndi() throws XAException, NamingException { JMSEndpoint endpoint=new JMSEndpoint("jms:queue:Foo.Bar?jndiTransactionManagerName=java:/comp/TransactionManager"); Assert.assertEquals("java:/comp/TransactionManager",endpoint.getJndiTransactionManagerName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testUsernameAndPassword() throws Exception { EndpointInfo ei=setupServiceInfo("HelloWorldService","HelloWorldPort"); JMSConfiguration config=JMSConfigFactory.createFromEndpointInfo(bus,ei,target); Assert.assertEquals("User name does not match.","testUser",config.getUserName()); Assert.assertEquals("Password does not match.","testPassword",config.getPassword()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testConcurrentConsumers(){ JMSEndpoint endpoint=new JMSEndpoint("jms:queue:Foo.Bar?concurrentConsumers=4"); JMSConfiguration jmsConfig=JMSConfigFactory.createFromEndpoint(bus,endpoint); Assert.assertEquals(4,jmsConfig.getConcurrentConsumers()); }

Class: org.apache.cxf.transport.jms.JMSDestinationTest

APIUtilityVerifier EqualityVerifier 
@Test public void testGetConfigurationFromWSDL() throws Exception { EndpointInfo ei=setupServiceInfo("HelloWorldQueueBinMsgService","HelloWorldQueueBinMsgPort"); JMSDestination destination=setupJMSDestination(ei); assertEquals("Can't get the right AddressPolicy's Destination","test.jmstransport.binary",destination.getJmsConfig().getTargetDestination()); destination.shutdown(); }

EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSecurityContext() throws Exception { SecurityContext ctx=testSecurityContext(true); assertNotNull("SecurityContext should be set in message received by JMSDestination",ctx); assertEquals("Principal in SecurityContext should be","testUser",ctx.getUserPrincipal().getName()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testRoundTripDestination() throws Exception { Message msg=testRoundTripDestination(true); SecurityContext securityContext=msg.get(SecurityContext.class); assertNotNull("SecurityContext should be set in message received by JMSDestination",securityContext); assertEquals("Principal in SecurityContext should be","testUser",securityContext.getUserPrincipal().getName()); }

Class: org.apache.cxf.transport.jms.JMSMessageUtilTest

UtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testGetEncoding() throws IOException { assertEquals("Get the wrong encoding",JMSMessageUtils.getEncoding("text/xml; charset=utf-8"),StandardCharsets.UTF_8.name()); assertEquals("Get the wrong encoding",JMSMessageUtils.getEncoding("text/xml"),StandardCharsets.UTF_8.name()); assertEquals("Get the wrong encoding",JMSMessageUtils.getEncoding("text/xml; charset=GBK"),"GBK"); try { JMSMessageUtils.getEncoding("text/xml; charset=asci"); fail("Expect the exception here"); } catch ( Exception ex) { assertTrue("we should get the UnsupportedEncodingException here",ex instanceof UnsupportedEncodingException); } }

Class: org.apache.cxf.transport.jms.continuations.JMSContinuationTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testSuspendResume(){ DummyCounter continuations=new DummyCounter(); JMSContinuation cw=new JMSContinuation(b,m,observer,continuations); cw.suspend(5000); Assert.assertEquals(1,continuations.counter.get()); assertFalse(cw.isNew()); assertTrue(cw.isPending()); assertFalse(cw.isResumed()); assertFalse(cw.suspend(1000)); Assert.assertEquals(1,continuations.counter.get()); observer.onMessage(m); EasyMock.expectLastCall(); EasyMock.replay(observer); cw.resume(); Assert.assertEquals(0,continuations.counter.get()); assertFalse(cw.isNew()); assertFalse(cw.isPending()); assertTrue(cw.isResumed()); EasyMock.verify(observer); }

Class: org.apache.cxf.transport.jms.uri.JMSEndpointTest

InternalCallVerifier EqualityVerifier 
@Test public void testRequestUriWithMessageType() throws Exception { JMSEndpoint endpoint=new JMSEndpoint("jms:queue:Foo.Bar?messageType=text"); assertEquals(JMSEndpoint.QUEUE,endpoint.getJmsVariant()); assertEquals("text",endpoint.getMessageType().value()); endpoint=new JMSEndpoint("jms:queue:Foo.Bar"); assertEquals(JMSEndpoint.QUEUE,endpoint.getJmsVariant()); assertEquals("byte",endpoint.getMessageType().value()); endpoint=new JMSEndpoint("jms:queue:Foo.Bar?messageType=binary"); assertEquals(JMSEndpoint.QUEUE,endpoint.getJmsVariant()); assertEquals("binary",endpoint.getMessageType().value()); }

InternalCallVerifier EqualityVerifier 
@Test public void testJNDIWithAdditionalParameters() throws Exception { JMSEndpoint endpoint=new JMSEndpoint("jms:jndi:Foo.Bar?" + "jndiInitialContextFactory" + "=org.apache.activemq.jndi.ActiveMQInitialContextFactory"+ "&jndiConnectionFactoryName=ConnectionFactory"+ "&jndiURL=tcp://localhost:61616"+ "&jndi-com.sun.jndi.someParameter=someValue"+ "&durableSubscriptionName=dur"); assertEquals(JMSEndpoint.JNDI,endpoint.getJmsVariant()); assertEquals(endpoint.getParameters().size(),0); assertEquals("org.apache.activemq.jndi.ActiveMQInitialContextFactory",endpoint.getJndiInitialContextFactory()); assertEquals("ConnectionFactory",endpoint.getJndiConnectionFactoryName()); assertEquals("tcp://localhost:61616",endpoint.getJndiURL()); assertEquals("dur",endpoint.getDurableSubscriptionName()); Map addParas=endpoint.getJndiParameters(); assertEquals(1,addParas.size()); assertEquals("someValue",addParas.get("com.sun.jndi.someParameter")); }

InternalCallVerifier EqualityVerifier 
@Test public void testSharedParameters() throws Exception { JMSEndpoint endpoint=new JMSEndpoint("jms:queue:Foo.Bar?" + "deliveryMode=NON_PERSISTENT" + "&timeToLive=100"+ "&priority=5"+ "&replyToName=foo.bar2"); assertEquals(JMSEndpoint.QUEUE,endpoint.getJmsVariant()); assertEquals(0,endpoint.getParameters().size()); assertEquals(DeliveryModeType.NON_PERSISTENT,endpoint.getDeliveryMode()); assertEquals(100,endpoint.getTimeToLive()); assertEquals(5,endpoint.getPriority()); assertEquals("foo.bar2",endpoint.getReplyToName()); }

InternalCallVerifier EqualityVerifier 
@Test public void testJaxWsProps() throws Exception { EndpointInfo ei=new EndpointInfo(); ei.setProperty(JMSEndpoint.JAXWS_PROPERTY_PREFIX + "durableSubscriptionName",TEST_VALUE); JMSEndpoint endpoint=new JMSEndpoint(ei,"jms:queue:Foo.Bar"); assertEquals(endpoint.getDurableSubscriptionName(),TEST_VALUE); }

InternalCallVerifier EqualityVerifier 
@Test public void testBasicJNDI() throws Exception { JMSEndpoint endpoint=new JMSEndpoint("jms:jndi:Foo.Bar"); assertEquals(JMSEndpoint.JNDI,endpoint.getJmsVariant()); assertEquals(endpoint.getDestinationName(),"Foo.Bar"); assertEquals(endpoint.getJmsVariant(),JMSEndpoint.JNDI); }

InternalCallVerifier EqualityVerifier 
@Test public void testTopicParameters() throws Exception { JMSEndpoint endpoint=new JMSEndpoint("jms:topic:Foo.Bar?foo=bar&foo2=bar2"); assertEquals(JMSEndpoint.TOPIC,endpoint.getJmsVariant()); assertEquals(endpoint.getParameters().size(),2); assertEquals(endpoint.getParameter("foo"),"bar"); assertEquals(endpoint.getParameter("foo2"),"bar2"); }

EqualityVerifier 
@Test public void nonSoapJMS() throws Exception { JMSEndpoint endpoint=new JMSEndpoint("jms://"); assertEquals(JMSEndpoint.QUEUE,endpoint.getJmsVariant()); }

EqualityVerifier 
@Test public void testTransactionManager(){ JMSEndpoint endpoint=new JMSEndpoint("jms:queue:Foo.Bar?jndiTransactionManagerName=test"); assertEquals("test",endpoint.getJndiTransactionManagerName()); }

InternalCallVerifier EqualityVerifier 
@Test public void testQueueParameters() throws Exception { JMSEndpoint endpoint=new JMSEndpoint("jms:queue:Foo.Bar?foo=bar&foo2=bar2&useConduitIdSelector=false"); assertEquals(JMSEndpoint.QUEUE,endpoint.getJmsVariant()); assertEquals(endpoint.getDestinationName(),"Foo.Bar"); assertEquals(endpoint.getJmsVariant(),JMSEndpoint.QUEUE); assertEquals(false,endpoint.isUseConduitIdSelector()); assertEquals(endpoint.getParameters().size(),2); assertEquals(endpoint.getParameter("foo"),"bar"); assertEquals(endpoint.getParameter("foo2"),"bar2"); }

InternalCallVerifier EqualityVerifier 
@Test public void testJNDIParameters() throws Exception { JMSEndpoint endpoint=new JMSEndpoint("jms:jndi:Foo.Bar?" + "jndiInitialContextFactory" + "=org.apache.activemq.jndi.ActiveMQInitialContextFactory"+ "&jndiConnectionFactoryName=ConnectionFactory"+ "&jndiURL=tcp://localhost:61616"); assertEquals(JMSEndpoint.JNDI,endpoint.getJmsVariant()); assertEquals(endpoint.getParameters().size(),0); assertEquals(endpoint.getDestinationName(),"Foo.Bar"); assertEquals(endpoint.getJndiInitialContextFactory(),"org.apache.activemq.jndi.ActiveMQInitialContextFactory"); assertEquals(endpoint.getJndiConnectionFactoryName(),"ConnectionFactory"); assertEquals(endpoint.getJndiURL(),"tcp://localhost:61616"); }

UtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testReplyToNameParameters() throws Exception { JMSEndpoint endpoint=new JMSEndpoint("jms:queue:Foo.Bar?replyToName=FOO.Tar"); assertEquals(JMSEndpoint.QUEUE,endpoint.getJmsVariant()); assertEquals("Foo.Bar",endpoint.getDestinationName()); assertNull(endpoint.getTopicReplyToName()); assertEquals("FOO.Tar",endpoint.getReplyToName()); try { new JMSEndpoint("jms:queue:Foo.Bar?replyToName=FOO.Tar&topicReplyToName=FOO.Zar"); fail("Expecting exception here"); } catch ( IllegalArgumentException ex) { } endpoint=new JMSEndpoint("jms:queue:Foo.Bar?topicReplyToName=FOO.Zar"); assertEquals("Foo.Bar",endpoint.getDestinationName()); assertNull(endpoint.getReplyToName()); assertEquals("FOO.Zar",endpoint.getTopicReplyToName()); }

InternalCallVerifier EqualityVerifier 
@Test public void testBasicTopic() throws Exception { JMSEndpoint endpoint=new JMSEndpoint("jms:topic:Foo.Bar"); assertEquals(JMSEndpoint.TOPIC,endpoint.getJmsVariant()); assertEquals(endpoint.getDestinationName(),"Foo.Bar"); assertEquals(endpoint.getJmsVariant(),JMSEndpoint.TOPIC); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testRequestUri() throws Exception { JMSEndpoint endpoint=new JMSEndpoint("jms:jndi:Foo.Bar" + "?jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory" + "&targetService=greetMe"+ "&replyToName=replyQueue"+ "&timeToLive=1000"+ "&priority=3"+ "&foo=bar"+ "&foo2=bar2"); assertEquals(JMSEndpoint.JNDI,endpoint.getJmsVariant()); assertEquals(2,endpoint.getParameters().size()); String requestUri=endpoint.getRequestURI(); assertTrue(requestUri.startsWith("jms:jndi:Foo.Bar?")); assertTrue(requestUri.contains("foo=bar")); assertTrue(requestUri.contains("foo2=bar2")); assertFalse(requestUri.contains("jndiInitialContextFactory")); assertFalse(requestUri.contains("targetService")); assertFalse(requestUri.contains("replyToName")); assertFalse(requestUri.contains("priority=3")); }

InternalCallVerifier EqualityVerifier 
@Test public void testBasicQueue() throws Exception { JMSEndpoint endpoint=new JMSEndpoint("jms:queue:Foo.Bar?concurrentConsumers=21"); assertEquals(JMSEndpoint.QUEUE,endpoint.getJmsVariant()); assertEquals("Foo.Bar",endpoint.getDestinationName()); assertEquals(JMSEndpoint.QUEUE,endpoint.getJmsVariant()); assertEquals(21,endpoint.getConcurrentConsumers()); }

Class: org.apache.cxf.transport.local.LocalDestinationTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
/** * Tests if the status code is available after closing the destination so that it can be logged. * Note that this test verifies the current approach of setting the status code if it is not set earlier. * @throws Exception */ @Test public void testStatusCodeSetAfterClose() throws Exception { Bus bus=BusFactory.getDefaultBus(); LocalTransportFactory factory=new LocalTransportFactory(); EndpointInfo ei=new EndpointInfo(null,"http://schemas.xmlsoap.org/soap/http"); ei.setAddress("http://localhost/test"); LocalDestination d=(LocalDestination)factory.getDestination(ei,bus); MessageImpl m=new MessageImpl(); Conduit conduit=factory.getConduit(ei,bus); m.put(LocalConduit.IN_CONDUIT,conduit); Exchange ex=new ExchangeImpl(); ex.put(Bus.class,bus); m.setExchange(ex); Integer code=(Integer)m.get(Message.RESPONSE_CODE); assertNull(code); Conduit backChannel=d.getBackChannel(m); backChannel.close(m); code=(Integer)m.get(Message.RESPONSE_CODE); assertNotNull(code); assertEquals(200,code.intValue()); }

Class: org.apache.cxf.transport.servlet.servicelist.BaseUrlHelperTest

EqualityVerifier 
@Test public void testGetRequestURLMultipleMatrixParam() throws Exception { String url=testGetBaseURL("http://localhost:8080/services/bar;a=b;c=d;e=f","","/services","/bar"); Assert.assertEquals("http://localhost:8080/services",url); }

EqualityVerifier 
@Test public void testGetRequestURL3() throws Exception { String url=testGetBaseURL("http://localhost:8080/services/bar","","","/services/bar"); Assert.assertEquals("http://localhost:8080",url); }

EqualityVerifier 
@Test public void testGetRequestURLWithRepeatingValues() throws Exception { String url=testGetBaseURL("http://services.com/services/bar","/services","","/bar"); Assert.assertEquals("http://services.com/services",url); }

EqualityVerifier 
@Test public void testGetRequestURL2() throws Exception { String url=testGetBaseURL("http://localhost:8080/services/bar","/services","","/bar"); Assert.assertEquals("http://localhost:8080/services",url); }

EqualityVerifier 
@Test public void testGetRequestURL() throws Exception { String url=testGetBaseURL("http://localhost:8080/services/bar","","/services","/bar"); Assert.assertEquals("http://localhost:8080/services",url); }

EqualityVerifier 
@Test public void testGetRequestURLSingleMatrixParam() throws Exception { String url=testGetBaseURL("http://localhost:8080/services/bar;a=b","","/services","/bar"); Assert.assertEquals("http://localhost:8080/services",url); }

EqualityVerifier 
@Test public void testGetRequestURLMultipleMatrixParam2() throws Exception { String url=testGetBaseURL("http://localhost:8080/services/bar;a=b;c=d;e=f","","/services","/bar;a=b;c=d"); Assert.assertEquals("http://localhost:8080/services",url); }

EqualityVerifier 
@Test public void testGetRequestURLMultipleMatrixParam3() throws Exception { String url=testGetBaseURL("http://localhost:8080/services/bar;a=b;c=d;e=f","","/services","/bar;a=b"); Assert.assertEquals("http://localhost:8080/services",url); }

EqualityVerifier 
@Test public void testGetRequestURLMultipleMatrixParam4() throws Exception { String url=testGetBaseURL("http://localhost:8080/services/bar;a=b;c=d;e=f;","","/services","/bar;a=b"); Assert.assertEquals("http://localhost:8080/services",url); }

Class: org.apache.cxf.transport.udp.UDPTransportTest

InternalCallVerifier EqualityVerifier 
@Test public void testBroadcastUDP() throws Exception { if (System.getProperties().getProperty("os.name").equals("Linux") && System.getProperties().getProperty("os.version").indexOf("el") > 0) { System.out.println("Skipping broadcast test for REL"); return; } Enumeration interfaces=NetworkInterface.getNetworkInterfaces(); int count=0; while (interfaces.hasMoreElements()) { NetworkInterface networkInterface=interfaces.nextElement(); if (!networkInterface.isUp() || networkInterface.isLoopback()) { continue; } count++; } if (count == 0) { System.out.println("Skipping broadcast test"); return; } JaxWsProxyFactoryBean fact=new JaxWsProxyFactoryBean(); fact.setAddress("udp://:" + PORT + "/foo"); Greeter g=fact.create(Greeter.class); assertEquals("Hello World",g.greetMe("World")); ((java.io.Closeable)g).close(); }

IterativeVerifier InternalCallVerifier EqualityVerifier 
@Test public void testSimpleUDP() throws Exception { JaxWsProxyFactoryBean fact=new JaxWsProxyFactoryBean(); fact.setAddress("udp://localhost:" + PORT); Greeter g=fact.create(Greeter.class); for (int x=0; x < 5; x++) { assertEquals("Hello World",g.greetMe("World")); } ((java.io.Closeable)g).close(); }

InternalCallVerifier EqualityVerifier 
@Test public void testLargeRequest() throws Exception { JaxWsProxyFactoryBean fact=new JaxWsProxyFactoryBean(); fact.setAddress("udp://localhost:" + PORT); Greeter g=fact.create(Greeter.class); StringBuilder b=new StringBuilder(100000); for (int x=0; x < 6500; x++) { b.append("Hello "); } assertEquals("Hello " + b.toString(),g.greetMe(b.toString())); ((java.io.Closeable)g).close(); }

Class: org.apache.cxf.transport.websocket.WebSocketUtilsTest

APIUtilityVerifier EqualityVerifier PublicFieldVerifier 
@Test public void testBuildResponse(){ byte[] r=WebSocketUtils.buildResponse(TEST_BODY_BYTES,0,TEST_BODY_BYTES.length); verifyBytes(CRLF,0,r,0,2); verifyBytes(TEST_BODY_BYTES,0,r,2,TEST_BODY_BYTES.length); assertEquals(2 + TEST_BODY_BYTES.length,r.length); r=WebSocketUtils.buildResponse(TEST_HEADERS_BYTES,TEST_BODY_BYTES,0,TEST_BODY_BYTES.length); verifyBytes(TEST_HEADERS_BYTES,0,r,0,TEST_HEADERS_BYTES.length); verifyBytes(CRLF,0,r,TEST_HEADERS_BYTES.length,2); verifyBytes(TEST_BODY_BYTES,0,r,TEST_HEADERS_BYTES.length + 2,TEST_BODY_BYTES.length); assertEquals(TEST_HEADERS_BYTES.length + 2 + TEST_BODY_BYTES.length,r.length); r=WebSocketUtils.buildResponse(TEST_HEADERS_MAP,TEST_BODY_BYTES,0,TEST_BODY_BYTES.length); verifyBytes(TEST_HEADERS_BYTES,0,r,0,TEST_HEADERS_BYTES.length); verifyBytes(TEST_ID_BYTES,0,r,TEST_HEADERS_BYTES.length,TEST_ID_BYTES.length); verifyBytes(CRLF,0,r,TEST_HEADERS_BYTES.length + TEST_ID_BYTES.length,2); verifyBytes(TEST_BODY_BYTES,0,r,TEST_HEADERS_BYTES.length + TEST_ID_BYTES.length + 2,TEST_BODY_BYTES.length); assertEquals(TEST_HEADERS_BYTES.length + TEST_ID_BYTES.length + 2+ TEST_BODY_BYTES.length,r.length); r=WebSocketUtils.buildResponse(TEST_BODY_BYTES,3,3); verifyBytes(CRLF,0,r,0,2); verifyBytes(TEST_BODY_BYTES,3,r,2,3); assertEquals(2 + 3,r.length); }

Class: org.apache.cxf.transport.websocket.ahc.AhcWebSocketConduitTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testResponseParsing() throws Exception { AhcWebSocketConduit.Response resp=new AhcWebSocketConduit.Response(WebSocketConstants.DEFAULT_RESPONSE_ID_KEY,TEST_RESPONSE1); assertEquals(200,resp.getStatusCode()); assertEquals("59610eed-d9de-4692-96d4-bb95a36c41ea",resp.getId()); assertEquals("text/plain",resp.getContentType()); assertTrue(resp.getEntity() instanceof String); assertEquals("Hola!",resp.getEntity()); resp=new AhcWebSocketConduit.Response(WebSocketConstants.DEFAULT_RESPONSE_ID_KEY,TEST_RESPONSE1.getBytes()); assertEquals(200,resp.getStatusCode()); assertEquals("59610eed-d9de-4692-96d4-bb95a36c41ea",resp.getId()); assertEquals("text/plain",resp.getContentType()); assertTrue(resp.getEntity() instanceof byte[]); assertEquals("Hola!",resp.getTextEntity()); resp=new AhcWebSocketConduit.Response(WebSocketConstants.DEFAULT_RESPONSE_ID_KEY,TEST_RESPONSE2); assertEquals(0,resp.getStatusCode()); assertEquals("59610eed-d9de-4692-96d4-bb95a36c41ea",resp.getId()); assertNull(resp.getContentType()); assertTrue(resp.getEntity() instanceof String); assertEquals("Nada!",resp.getEntity()); resp=new AhcWebSocketConduit.Response(WebSocketConstants.DEFAULT_RESPONSE_ID_KEY,TEST_RESPONSE2.getBytes()); assertEquals(0,resp.getStatusCode()); assertEquals("59610eed-d9de-4692-96d4-bb95a36c41ea",resp.getId()); assertNull(resp.getContentType()); assertTrue(resp.getEntity() instanceof byte[]); assertEquals("Nada!",resp.getTextEntity()); }

Class: org.apache.cxf.transport.websocket.atmosphere.AtmosphereWebSocketJettyDestinationTest

EqualityVerifier 
@Test public void testUseCustomAtmoosphereInterceptor() throws Exception { Bus bus=new ExtensionManagerBus(); bus.setProperty("atmosphere.interceptors",new CustomInterceptor1()); DestinationRegistry registry=new HTTPTransportFactory().getRegistry(); EndpointInfo endpoint=new EndpointInfo(); endpoint.setAddress(ENDPOINT_ADDRESS); endpoint.setName(ENDPOINT_NAME); AtmosphereWebSocketServletDestination dest=new AtmosphereWebSocketServletDestination(bus,registry,endpoint,ENDPOINT_ADDRESS); List ais=dest.getAtmosphereFramework().interceptors(); int added=0; for ( AtmosphereInterceptor a : ais) { if (CustomInterceptor1.class.equals(a.getClass())) { added++; break; } } assertEquals(1,added); }

EqualityVerifier 
@Test public void testUseCustomAtmoosphereInterceptors() throws Exception { Bus bus=new ExtensionManagerBus(); bus.setProperty("atmosphere.interceptors",Arrays.asList(new CustomInterceptor1(),new CustomInterceptor2())); DestinationRegistry registry=new HTTPTransportFactory().getRegistry(); EndpointInfo endpoint=new EndpointInfo(); endpoint.setAddress(ENDPOINT_ADDRESS); endpoint.setName(ENDPOINT_NAME); AtmosphereWebSocketServletDestination dest=new AtmosphereWebSocketServletDestination(bus,registry,endpoint,ENDPOINT_ADDRESS); List ais=dest.getAtmosphereFramework().interceptors(); int added=0; for ( AtmosphereInterceptor a : ais) { if (CustomInterceptor1.class.equals(a.getClass())) { added++; } else if (CustomInterceptor2.class.equals(a.getClass())) { added++; break; } } assertEquals(2,added); }

EqualityVerifier 
@Test public void testUseCXFDefaultAtmoosphereInterceptor() throws Exception { Bus bus=new ExtensionManagerBus(); DestinationRegistry registry=new HTTPTransportFactory().getRegistry(); EndpointInfo endpoint=new EndpointInfo(); endpoint.setAddress(ENDPOINT_ADDRESS); endpoint.setName(ENDPOINT_NAME); AtmosphereWebSocketServletDestination dest=new AtmosphereWebSocketServletDestination(bus,registry,endpoint,ENDPOINT_ADDRESS); List ais=dest.getAtmosphereFramework().interceptors(); int added=0; for ( AtmosphereInterceptor a : ais) { if (DefaultProtocolInterceptor.class.equals(a.getClass())) { added++; break; } } assertEquals(1,added); }

Class: org.apache.cxf.transport.websocket.atmosphere.AtmosphereWebSocketServletDestinationTest

EqualityVerifier 
@Test public void testUseCXFDefaultAtmoosphereInterceptor() throws Exception { Bus bus=new ExtensionManagerBus(); DestinationRegistry registry=new HTTPTransportFactory().getRegistry(); EndpointInfo endpoint=new EndpointInfo(); endpoint.setAddress(ENDPOINT_ADDRESS); endpoint.setName(ENDPOINT_NAME); AtmosphereWebSocketServletDestination dest=new AtmosphereWebSocketServletDestination(bus,registry,endpoint,ENDPOINT_ADDRESS); List ais=dest.getAtmosphereFramework().interceptors(); int added=0; for ( AtmosphereInterceptor a : ais) { if (DefaultProtocolInterceptor.class.equals(a.getClass())) { added++; break; } } assertEquals(1,added); }

EqualityVerifier 
@Test public void testUseCustomAtmoosphereInterceptor() throws Exception { Bus bus=new ExtensionManagerBus(); bus.setProperty("atmosphere.interceptors",new CustomInterceptor1()); DestinationRegistry registry=new HTTPTransportFactory().getRegistry(); EndpointInfo endpoint=new EndpointInfo(); endpoint.setAddress(ENDPOINT_ADDRESS); endpoint.setName(ENDPOINT_NAME); AtmosphereWebSocketServletDestination dest=new AtmosphereWebSocketServletDestination(bus,registry,endpoint,ENDPOINT_ADDRESS); List ais=dest.getAtmosphereFramework().interceptors(); int added=0; for ( AtmosphereInterceptor a : ais) { if (CustomInterceptor1.class.equals(a.getClass())) { added++; break; } } assertEquals(1,added); }

EqualityVerifier 
@Test public void testUseCustomAtmoosphereInterceptors() throws Exception { Bus bus=new ExtensionManagerBus(); bus.setProperty("atmosphere.interceptors",Arrays.asList(new CustomInterceptor1(),new CustomInterceptor2())); DestinationRegistry registry=new HTTPTransportFactory().getRegistry(); EndpointInfo endpoint=new EndpointInfo(); endpoint.setAddress(ENDPOINT_ADDRESS); endpoint.setName(ENDPOINT_NAME); AtmosphereWebSocketServletDestination dest=new AtmosphereWebSocketServletDestination(bus,registry,endpoint,ENDPOINT_ADDRESS); List ais=dest.getAtmosphereFramework().interceptors(); int added=0; for ( AtmosphereInterceptor a : ais) { if (CustomInterceptor1.class.equals(a.getClass())) { added++; } else if (CustomInterceptor2.class.equals(a.getClass())) { added++; break; } } assertEquals(2,added); }

Class: org.apache.cxf.workqueue.AutomaticWorkQueueTest

IterativeVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier IgnoredMethod HybridVerifier 
@Test @Ignore("The test is failed on openjdk") public void testEnqueueImmediate(){ workqueue=new AutomaticWorkQueueImpl(DEFAULT_MAX_QUEUE_SIZE,INITIAL_SIZE,DEFAULT_HIGH_WATER_MARK,DEFAULT_LOW_WATER_MARK,DEFAULT_DEQUEUE_TIMEOUT); try { Thread.sleep(100); } catch ( Exception e) { } assertEquals(0,workqueue.getSize()); assertEquals(0,workqueue.getPoolSize()); assertEquals(0,workqueue.getActiveCount()); BlockingWorkItem[] workItems=new BlockingWorkItem[DEFAULT_HIGH_WATER_MARK]; BlockingWorkItem[] fillers=new BlockingWorkItem[DEFAULT_MAX_QUEUE_SIZE]; try { for (int i=0; i < DEFAULT_HIGH_WATER_MARK; i++) { workItems[i]=new BlockingWorkItem(); try { workqueue.execute(workItems[i]); } catch ( RejectedExecutionException ex) { fail("failed on item[" + i + "] with: "+ ex); } } while (workqueue.getActiveCount() < DEFAULT_HIGH_WATER_MARK) { try { Thread.sleep(250); } catch ( InterruptedException ex) { } } for (int i=0; i < DEFAULT_MAX_QUEUE_SIZE; i++) { fillers[i]=new BlockingWorkItem(); try { workqueue.execute(fillers[i]); } catch ( RejectedExecutionException ex) { fail("failed on filler[" + i + "] with: "+ ex); } } try { Thread.sleep(250); } catch ( InterruptedException ex) { } assertTrue(workqueue.toString(),workqueue.isFull()); assertEquals(workqueue.toString(),DEFAULT_HIGH_WATER_MARK,workqueue.getPoolSize()); assertEquals(workqueue.toString(),DEFAULT_HIGH_WATER_MARK,workqueue.getActiveCount()); try { workqueue.execute(new BlockingWorkItem()); fail("workitem should not have been accepted."); } catch ( RejectedExecutionException ex) { } workItems[0].unblock(); boolean accepted=false; workItems[0]=new BlockingWorkItem(); for (int i=0; i < 20 && !accepted; i++) { try { Thread.sleep(100); } catch ( InterruptedException ex) { } try { workqueue.execute(workItems[0]); accepted=true; } catch ( RejectedExecutionException ex) { } } assertTrue(accepted); } finally { for (int i=0; i < DEFAULT_HIGH_WATER_MARK; i++) { if (workItems[i] != null) { workItems[i].unblock(); } } for (int i=0; i < DEFAULT_MAX_QUEUE_SIZE; i++) { if (fillers[i] != null) { fillers[i].unblock(); } } } }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testConstructor(){ workqueue=new AutomaticWorkQueueImpl(DEFAULT_MAX_QUEUE_SIZE,INITIAL_SIZE,DEFAULT_HIGH_WATER_MARK,DEFAULT_LOW_WATER_MARK,DEFAULT_DEQUEUE_TIMEOUT); assertNotNull(workqueue); assertEquals(DEFAULT_MAX_QUEUE_SIZE,workqueue.getMaxSize()); assertEquals(DEFAULT_HIGH_WATER_MARK,workqueue.getHighWaterMark()); assertEquals(DEFAULT_LOW_WATER_MARK,workqueue.getLowWaterMark()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testUnboundedConstructor(){ workqueue=new AutomaticWorkQueueImpl(UNBOUNDED_MAX_QUEUE_SIZE,INITIAL_SIZE,UNBOUNDED_HIGH_WATER_MARK,UNBOUNDED_LOW_WATER_MARK,DEFAULT_DEQUEUE_TIMEOUT); assertNotNull(workqueue); assertEquals(AutomaticWorkQueueImpl.DEFAULT_MAX_QUEUE_SIZE,workqueue.getMaxSize()); assertEquals(UNBOUNDED_HIGH_WATER_MARK,workqueue.getHighWaterMark()); assertEquals(UNBOUNDED_LOW_WATER_MARK,workqueue.getLowWaterMark()); }

InternalCallVerifier EqualityVerifier 
@Test public void testShutdown(){ workqueue=new AutomaticWorkQueueImpl(DEFAULT_MAX_QUEUE_SIZE,INITIAL_SIZE,INITIAL_SIZE,INITIAL_SIZE,500); assertEquals(0,workqueue.getSize()); DeadLockThread dead=new DeadLockThread(workqueue,10,5L); dead.start(); checkCompleted(dead); workqueue.shutdown(true); for (int i=0; i < 20 && (workqueue.getSize() > 0 || workqueue.getPoolSize() > 0); i++) { try { Thread.sleep(250); } catch ( InterruptedException ie) { } } assertEquals(0,workqueue.getSize()); assertEquals(0,workqueue.getPoolSize()); workqueue=null; }

InternalCallVerifier EqualityVerifier 
@Test public void testEnqueue(){ workqueue=new AutomaticWorkQueueImpl(DEFAULT_MAX_QUEUE_SIZE,INITIAL_SIZE,DEFAULT_HIGH_WATER_MARK,DEFAULT_LOW_WATER_MARK,DEFAULT_DEQUEUE_TIMEOUT); try { Thread.sleep(100); } catch ( Exception e) { } assertEquals(0,workqueue.getSize()); assertEquals(0,workqueue.getPoolSize()); assertEquals(0,workqueue.getActiveCount()); workqueue.execute(new TestWorkItem(),TIMEOUT); int i=0; while (workqueue.getSize() != 0 && i++ < 50) { try { Thread.sleep(100); } catch ( InterruptedException ie) { } } assertEquals(0,workqueue.getSize()); }

Class: org.apache.cxf.ws.addressing.AddressingConstantsImplTest

EqualityVerifier 
@Test public void testActionNotSupportedText() throws Exception { assertEquals("unexpected constant","Action {0} not supported",constants.getActionNotSupportedText()); }

EqualityVerifier 
@Test public void testGetNoneURI() throws Exception { assertEquals("unexpected constant","http://www.w3.org/2005/08/addressing/none",constants.getNoneURI()); }

EqualityVerifier 
@Test public void testEndpointUnavailableQName() throws Exception { assertEquals("unexpected constant",new QName("http://www.w3.org/2005/08/addressing","EndpointUnavailable"),constants.getEndpointUnavailableQName()); }

EqualityVerifier 
@Test public void testGetFromQName() throws Exception { assertEquals("unexpected constant",new QName("http://www.w3.org/2005/08/addressing","From"),constants.getFromQName()); }

EqualityVerifier 
@Test public void testGetIsReferenceParameterQName() throws Exception { assertEquals("unexpected constant",new QName("http://www.w3.org/2005/08/addressing","IsReferenceParameter"),constants.getIsReferenceParameterQName()); }

EqualityVerifier 
@Test public void testGetRelatesToQName() throws Exception { assertEquals("unexpected constant",new QName("http://www.w3.org/2005/08/addressing","RelatesTo"),constants.getRelatesToQName()); }

EqualityVerifier 
@Test public void testDestinationUnreachableQName() throws Exception { assertEquals("unexpected constant",new QName("http://www.w3.org/2005/08/addressing","DestinationUnreachable"),constants.getDestinationUnreachableQName()); }

EqualityVerifier 
@Test public void testGetRelationshipTypeQName() throws Exception { assertEquals("unexpected constant",new QName("http://www.w3.org/2005/08/addressing","RelationshipType"),constants.getRelationshipTypeQName()); }

EqualityVerifier 
@Test public void testGetNamespaceURI() throws Exception { assertEquals("unexpected constant","http://www.w3.org/2005/08/addressing",constants.getNamespaceURI()); }

EqualityVerifier 
@Test public void testMapRequiredQName() throws Exception { assertEquals("unexpected constant",new QName("http://www.w3.org/2005/08/addressing","MessageAddressingPropertyRequired"),constants.getMapRequiredQName()); }

EqualityVerifier 
@Test public void testGetInvalidMapQName() throws Exception { assertEquals("unexpected constant",new QName("http://www.w3.org/2005/08/addressing","InvalidMessageAddressingProperty"),constants.getInvalidMapQName()); }

EqualityVerifier 
@Test public void testGetActionQName() throws Exception { assertEquals("unexpected constant",new QName("http://www.w3.org/2005/08/addressing","Action"),constants.getActionQName()); }

EqualityVerifier 
@Test public void testMapRequiredText() throws Exception { assertEquals("unexpected constant","Message Addressing Property {0} required",constants.getMapRequiredText()); }

EqualityVerifier 
@Test public void testGetAddressQName() throws Exception { assertEquals("unexpected constant",new QName("http://www.w3.org/2005/08/addressing","Address"),constants.getAddressQName()); }

EqualityVerifier 
@Test public void testGetWSDLActionQName() throws Exception { assertEquals("unexpected constant",new QName("http://www.w3.org/2006/05/addressing/wsdl","Action"),constants.getWSDLActionQName()); }

EqualityVerifier 
@Test public void testGetReplyToQName() throws Exception { assertEquals("unexpected constant",new QName("http://www.w3.org/2005/08/addressing","ReplyTo"),constants.getReplyToQName()); }

EqualityVerifier 
@Test public void testDefaultFaultAction() throws Exception { assertEquals("unexpected constant","http://www.w3.org/2005/08/addressing/fault",constants.getDefaultFaultAction()); }

EqualityVerifier 
@Test public void testGetWSDLNamespaceURI() throws Exception { assertEquals("unexpected constant","http://www.w3.org/2006/05/addressing/wsdl",constants.getWSDLNamespaceURI()); }

EqualityVerifier 
@Test public void testGetMetadataQName() throws Exception { assertEquals("unexpected constant",new QName("http://www.w3.org/2005/08/addressing","Metadata"),constants.getMetadataQName()); }

EqualityVerifier 
@Test public void testGetAnonymousURI() throws Exception { assertEquals("unexpected constant","http://www.w3.org/2005/08/addressing/anonymous",constants.getAnonymousURI()); }

EqualityVerifier 
@Test public void testActionNotSupportedQName() throws Exception { assertEquals("unexpected constant",new QName("http://www.w3.org/2005/08/addressing","ActionNotSupported"),constants.getActionNotSupportedQName()); }

EqualityVerifier 
@Test public void testGetWSDLExtensibility() throws Exception { assertEquals("unexpected constant",new QName("http://www.w3.org/2006/05/addressing/wsdl","UsingAddressing"),constants.getWSDLExtensibilityQName()); }

EqualityVerifier 
@Test public void testDestinationUnreachableText() throws Exception { assertEquals("unexpected constant","Destination {0} unreachable",constants.getDestinationUnreachableText()); }

EqualityVerifier 
@Test public void testGetToQName() throws Exception { assertEquals("unexpected constant",new QName("http://www.w3.org/2005/08/addressing","To"),constants.getToQName()); }

EqualityVerifier 
@Test public void testGetInvalidMapText() throws Exception { assertEquals("unexpected constant","Invalid Message Addressing Property {0}",constants.getInvalidMapText()); }

EqualityVerifier 
@Test public void testEndpointUnavailableText() throws Exception { assertEquals("unexpected constant","Endpoint {0} unavailable",constants.getEndpointUnavailableText()); }

EqualityVerifier 
@Test public void testGetRelationshipReply() throws Exception { assertEquals("unexpected constant","http://www.w3.org/2005/08/addressing/reply",constants.getRelationshipReply()); }

EqualityVerifier 
@Test public void testGetFaultToQName() throws Exception { assertEquals("unexpected constant",new QName("http://www.w3.org/2005/08/addressing","FaultTo"),constants.getFaultToQName()); }

EqualityVerifier 
@Test public void testDuplicateMessageIDText() throws Exception { assertEquals("unexpected constant","Duplicate Message ID {0}",constants.getDuplicateMessageIDText()); }

EqualityVerifier 
@Test public void testGetMessageIDQName() throws Exception { assertEquals("unexpected constant",new QName("http://www.w3.org/2005/08/addressing","MessageID"),constants.getMessageIDQName()); }

Class: org.apache.cxf.ws.addressing.impl.ContextUtilsTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetActionFromExtensible(){ Map attributes=new HashMap(); Extensible ext=control.createMock(Extensible.class); EasyMock.expect(ext.getExtensionAttributes()).andReturn(attributes).anyTimes(); attributes.put(WSA_ACTION_QNAME,"urn:foo:test:2"); EasyMock.expect(ext.getExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME)).andReturn("urn:foo:test:1"); control.replay(); String action=InternalContextUtils.getAction(ext); assertEquals("urn:foo:test:1",action); control.reset(); attributes.clear(); EasyMock.expect(ext.getExtensionAttributes()).andReturn(attributes).anyTimes(); EasyMock.expect(ext.getExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME)).andReturn(null); attributes.put(WSA_ACTION_QNAME,"urn:foo:test:2"); control.replay(); action=InternalContextUtils.getAction(ext); assertEquals("urn:foo:test:2",action); control.reset(); attributes.clear(); EasyMock.expect(ext.getExtensionAttributes()).andReturn(attributes).anyTimes(); EasyMock.expect(ext.getExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME)).andReturn(null); attributes.put(OLD_WSDL_WSA_ACTION_QNAME,"urn:foo:test:3"); control.replay(); action=InternalContextUtils.getAction(ext); assertEquals("urn:foo:test:3",action); control.reset(); attributes.clear(); EasyMock.expect(ext.getExtensionAttributes()).andReturn(attributes).anyTimes(); EasyMock.expect(ext.getExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME)).andReturn(null); control.replay(); action=InternalContextUtils.getAction(ext); assertEquals(null,action); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetActionFromMessage(){ Message msg=control.createMock(Message.class); Exchange exchange=control.createMock(Exchange.class); QName mqname=new QName("http://foo.com","bar"); QName fqname=new QName("urn:foo:test:4","fault"); OperationInfo operationInfo=new OperationInfo(); MessageInfo messageInfo=new MessageInfo(operationInfo,Type.OUTPUT,mqname); messageInfo.addMessagePart(new MessagePartInfo(new QName("http://foo.com","partInfo"),null)); operationInfo.setOutput("outputName",messageInfo); FaultInfo faultInfo=new FaultInfo(fqname,mqname,operationInfo); operationInfo.addFault(faultInfo); BindingOperationInfo boi=new BindingOperationInfo(null,operationInfo); EasyMock.expect(msg.getExchange()).andReturn(exchange).anyTimes(); EasyMock.expect(exchange.getBindingOperationInfo()).andReturn(boi); EasyMock.expect(msg.get(ContextUtils.ACTION)).andReturn("urn:foo:test:1"); control.replay(); AttributedURIType action=InternalContextUtils.getAction(msg); assertNotNull(action); assertEquals("urn:foo:test:1",action.getValue()); control.reset(); EasyMock.expect(msg.getExchange()).andReturn(exchange).anyTimes(); EasyMock.expect(exchange.getBindingOperationInfo()).andReturn(boi); EasyMock.expect(msg.get(SoapBindingConstants.SOAP_ACTION)).andReturn("urn:foo:test:2"); control.replay(); action=InternalContextUtils.getAction(msg); assertNotNull(action); assertEquals("urn:foo:test:2",action.getValue()); control.reset(); EasyMock.expect(msg.getExchange()).andReturn(exchange).anyTimes(); EasyMock.expect(exchange.getBindingOperationInfo()).andReturn(boi); messageInfo.setProperty(ContextUtils.ACTION,"urn:foo:test:3"); control.replay(); action=InternalContextUtils.getAction(msg); assertNotNull(action); assertEquals("urn:foo:test:3",action.getValue()); control.reset(); SoapFault fault=new SoapFault("faulty service",new RuntimeException(),fqname); EasyMock.expect(msg.getExchange()).andReturn(exchange).anyTimes(); EasyMock.expect(msg.getContent(Exception.class)).andReturn(fault).anyTimes(); EasyMock.expect(exchange.getBindingOperationInfo()).andReturn(boi); control.replay(); action=InternalContextUtils.getAction(msg); assertNull(action); control.reset(); faultInfo.addMessagePart(new MessagePartInfo(new QName("http://foo.com","faultInfo"),null)); faultInfo.getMessagePart(0).setTypeClass(RuntimeException.class); faultInfo.addExtensionAttribute(Names.WSAW_ACTION_QNAME,"urn:foo:test:4"); EasyMock.expect(msg.getExchange()).andReturn(exchange).anyTimes(); EasyMock.expect(msg.getContent(Exception.class)).andReturn(fault).anyTimes(); EasyMock.expect(exchange.getBindingOperationInfo()).andReturn(boi); control.replay(); action=InternalContextUtils.getAction(msg); assertNotNull(action); assertEquals("urn:foo:test:4",action.getValue()); control.reset(); fault=new SoapFault("Action Mismatch",new QName(Names.WSA_NAMESPACE_NAME,Names.ACTION_MISMATCH_NAME)); EasyMock.expect(msg.getExchange()).andReturn(exchange).anyTimes(); EasyMock.expect(msg.getContent(Exception.class)).andReturn(fault).anyTimes(); EasyMock.expect(exchange.getBindingOperationInfo()).andReturn(boi); control.replay(); action=InternalContextUtils.getAction(msg); assertNotNull(action); assertEquals(Names.WSA_DEFAULT_FAULT_ACTION,action.getValue()); control.reset(); fault=new SoapFault("faulty service",new TestFault(),Fault.FAULT_CODE_SERVER); faultInfo.addMessagePart(new MessagePartInfo(new QName("http://foo.com:7","faultInfo"),null)); faultInfo.getMessagePart(0).setTypeClass(Object.class); faultInfo.getMessagePart(0).setConcreteName(new QName("urn:foo:test:7","testFault")); faultInfo.addExtensionAttribute(Names.WSAW_ACTION_QNAME,"urn:foo:test:7"); EasyMock.expect(msg.getExchange()).andReturn(exchange).anyTimes(); EasyMock.expect(msg.getContent(Exception.class)).andReturn(fault).anyTimes(); EasyMock.expect(exchange.getBindingOperationInfo()).andReturn(boi); control.replay(); action=InternalContextUtils.getAction(msg); assertNotNull(action); assertEquals("urn:foo:test:7",action.getValue()); }

Class: org.apache.cxf.ws.addressing.impl.MAPAggregatorTest

InternalCallVerifier EqualityVerifier 
@Test public void testGetActionUriForNormalOp() throws Exception { Message message=setUpMessage(true,true,false,true,true); String action=aggregator.getActionUri(message,false); control.verify(); assertEquals("http://foo/bar/SEI/opRequest",action); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetReplyToUsingBaseAddress() throws Exception { Message message=new MessageImpl(); Exchange exchange=new ExchangeImpl(); message.setExchange(exchange); final String localReplyTo="/SoapContext/decoupled"; final String decoupledEndpointBase="http://localhost:8181/cxf"; final String replyTo=decoupledEndpointBase + localReplyTo; ServiceInfo s=new ServiceInfo(); Service svc=new ServiceImpl(s); EndpointInfo ei=new EndpointInfo(); InterfaceInfo ii=s.createInterface(new QName("FooInterface")); s.setInterface(ii); ii.addOperation(new QName("fooOp")); SoapBindingInfo b=new SoapBindingInfo(s,"http://schemas.xmlsoap.org/soap/",Soap11.getInstance()); b.setTransportURI("http://schemas.xmlsoap.org/soap/http"); ei.setBinding(b); ei.setAddress("http://nowhere.com/bar/foo"); ei.setName(new QName("http://nowhere.com/port","foo")); Bus bus=new ExtensionManagerBus(); DestinationFactoryManager dfm=control.createMock(DestinationFactoryManager.class); DestinationFactory df=control.createMock(DestinationFactory.class); Destination d=control.createMock(Destination.class); bus.setExtension(dfm,DestinationFactoryManager.class); EasyMock.expect(dfm.getDestinationFactoryForUri(localReplyTo)).andReturn(df); EasyMock.expect(df.getDestination(EasyMock.anyObject(EndpointInfo.class),EasyMock.anyObject(Bus.class))).andReturn(d); EasyMock.expect(d.getAddress()).andReturn(EndpointReferenceUtils.getEndpointReference(localReplyTo)); Endpoint ep=new EndpointImpl(bus,svc,ei); exchange.put(Endpoint.class,ep); exchange.put(Bus.class,bus); exchange.setOutMessage(message); setUpMessageProperty(message,REQUESTOR_ROLE,Boolean.TRUE); message.getContextualProperty(WSAContextUtils.REPLYTO_PROPERTY); message.put(WSAContextUtils.REPLYTO_PROPERTY,localReplyTo); message.put(WSAContextUtils.DECOUPLED_ENDPOINT_BASE_PROPERTY,decoupledEndpointBase); AddressingProperties maps=new AddressingProperties(); AttributedURIType id=ContextUtils.getAttributedURI("urn:uuid:12345"); maps.setMessageID(id); maps.setAction(ContextUtils.getAttributedURI("")); setUpMessageProperty(message,CLIENT_ADDRESSING_PROPERTIES,maps); control.replay(); aggregator.mediate(message,false); AddressingProperties props=(AddressingProperties)message.get(JAXWSAConstants.ADDRESSING_PROPERTIES_OUTBOUND); assertEquals(replyTo,props.getReplyTo().getAddress().getValue()); control.verify(); }

Class: org.apache.cxf.ws.addressing.soap.DecoupledFaultHandlerTest

BooleanVerifier InternalCallVerifier IdentityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testOnewayFault(){ DecoupledFaultHandler handler=new DecoupledFaultHandler(){ protected Destination createDecoupledDestination( Exchange exchange, EndpointReferenceType epr){ assertEquals("http://bar",epr.getAddress().getValue()); return EasyMock.createMock(Destination.class); } } ; SoapMessage message=new SoapMessage(new MessageImpl()); QName qname=new QName("http://cxf.apache.org/mustunderstand","TestMU"); message.getHeaders().add(new Header(qname,new Object())); AddressingProperties maps=new AddressingProperties(); EndpointReferenceType faultTo=new EndpointReferenceType(); faultTo.setAddress(new AttributedURIType()); faultTo.getAddress().setValue("http://bar"); maps.setFaultTo(faultTo); message.put(ContextUtils.getMAPProperty(false,false,false),maps); Exchange exchange=new ExchangeImpl(); message.setExchange(exchange); exchange.setInMessage(message); exchange.setOneWay(true); handler.handleFault(message); assertTrue(message.getHeaders().isEmpty()); assertFalse(exchange.isOneWay()); assertSame(message,exchange.getOutMessage()); assertNotNull(exchange.getDestination()); }

Class: org.apache.cxf.ws.addressing.soap.MAPCodecTest

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testResponderOutboundInvalidMAP() throws Exception { SoapMessage message=setUpMessage(false,true,true); try { codec.handleMessage(message); fail("expected SOAPFaultException on invalid MAP"); } catch ( SoapFault sfe) { assertEquals("unexpected fault string","Duplicate Message ID urn:uuid:12345",sfe.getMessage()); } control.verify(); verifyMessage(message,false,true,true); }

Class: org.apache.cxf.ws.discovery.WSDiscoveryClientTest

InternalCallVerifier EqualityVerifier 
@Test public void testMultiResponses() throws Exception { if (System.getProperties().getProperty("os.name").equals("Linux") && System.getProperties().getProperty("os.version").indexOf("el") > 0) { System.out.println("Skipping MultiResponse test for REL"); return; } Enumeration interfaces=NetworkInterface.getNetworkInterfaces(); int count=0; while (interfaces.hasMoreElements()) { NetworkInterface networkInterface=interfaces.nextElement(); if (!networkInterface.isUp() || networkInterface.isLoopback()) { continue; } count++; } if (count == 0) { System.out.println("Skipping MultiResponse test"); return; } new Thread(new Runnable(){ public void run(){ try { InetAddress address=InetAddress.getByName("239.255.255.250"); MulticastSocket s=new MulticastSocket(Integer.parseInt(PORT)); s.setBroadcast(true); s.setNetworkInterface(findIpv4Interface()); s.joinGroup(address); s.setReceiveBufferSize(64 * 1024); s.setSoTimeout(5000); byte[] bytes=new byte[64 * 1024]; DatagramPacket p=new DatagramPacket(bytes,bytes.length,address,Integer.parseInt(PORT)); s.receive(p); SocketAddress sa=p.getSocketAddress(); String incoming=new String(p.getData(),0,p.getLength(),StandardCharsets.UTF_8); int idx=incoming.indexOf("MessageID"); idx=incoming.indexOf('>',idx); incoming=incoming.substring(idx + 1); idx=incoming.indexOf("

Class: org.apache.cxf.ws.policy.AssertionBuilderRegistryImplTest

IterativeVerifier UtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testBuildUnknownAssertion(){ Bus bus=control.createMock(Bus.class); PolicyBuilder builder=control.createMock(PolicyBuilder.class); EasyMock.expect(bus.getExtension(PolicyBuilder.class)).andReturn(builder).anyTimes(); AssertionBuilderRegistryImpl reg=new AssertionBuilderRegistryImpl(){ protected void loadDynamic(){ } } ; reg.setIgnoreUnknownAssertions(false); Element[] elems=new Element[11]; QName[] qnames=new QName[11]; for (int i=0; i < 11; i++) { qnames[i]=new QName("http://my.company.com","type" + Integer.toString(i)); elems[i]=control.createMock(Element.class); EasyMock.expect(elems[i].getNamespaceURI()).andReturn(qnames[i].getNamespaceURI()).anyTimes(); EasyMock.expect(elems[i].getLocalName()).andReturn(qnames[i].getLocalPart()).anyTimes(); } control.replay(); reg.setBus(bus); assertTrue(!reg.isIgnoreUnknownAssertions()); try { reg.build(elems[0]); fail("Expected PolicyException not thrown."); } catch ( PolicyException ex) { assertEquals("NO_ASSERTIONBUILDER_EXC",ex.getCode()); } reg.setIgnoreUnknownAssertions(true); assertTrue(reg.isIgnoreUnknownAssertions()); for (int i=0; i < 10; i++) { Assertion assertion=reg.build(elems[i]); assertTrue("Not a PrimitiveAsertion: " + assertion.getClass().getName(),assertion instanceof PrimitiveAssertion); } for (int i=9; i >= 0; i--) { assertTrue(reg.build(elems[i]) instanceof PrimitiveAssertion); } assertTrue(reg.build(elems[10]) instanceof PrimitiveAssertion); }

Class: org.apache.cxf.ws.policy.AssertionInfoMapTest

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testCheck() throws PolicyException { QName aqn=new QName("http://x.y.z","a"); Assertion a=new PrimitiveAssertion(aqn); Collection assertions=new ArrayList(); assertions.add(a); AssertionInfoMap aim=new AssertionInfoMap(assertions); try { aim.check(); fail("Expected PolicyException not thrown."); } catch ( PolicyException ex) { assertEquals("NOT_ASSERTED_EXC",ex.getCode()); } aim.get(aqn).iterator().next().setAsserted(true); aim.check(); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testAllAssertionsIn(){ Policy nested=new Policy(); Assertion nb=new PrimitiveAssertion(new QName("http://x.y.z","b")); nested.addAssertion(nb); Policy p=new Policy(); Assertion a1=new PrimitiveAssertion(new QName("http://x.y.z","a")); Assertion a2=new PrimitiveAssertion(new QName("http://x.y.z","a")); Assertion b=new PrimitiveAssertion(new QName("http://x.y.z","b")); Assertion c=new PolicyContainingPrimitiveAssertion(new QName("http://x.y.z","c"),false,false,nested); All alt1=new All(); alt1.addAssertion(a1); alt1.addAssertion(b); All alt2=new All(); alt1.addAssertion(a2); alt2.addAssertion(c); ExactlyOne ea=new ExactlyOne(); ea.addPolicyComponent(alt1); ea.addPolicyComponent(alt2); p.addPolicyComponent(ea); AssertionInfoMap aim=new AssertionInfoMap(p); Collection listA=aim.getAssertionInfo(new QName("http://x.y.z","a")); assertEquals("2 A assertions should've been added",2,listA.size()); AssertionInfo[] ais=listA.toArray(new AssertionInfo[]{}); assertTrue("Two different A instances should be added",ais[0].getAssertion() == a1 && ais[1].getAssertion() == a2 || ais[0].getAssertion() == a2 && ais[1].getAssertion() == a1); Collection listB=aim.getAssertionInfo(new QName("http://x.y.z","b")); assertEquals("2 B assertions should've been added",2,listB.size()); ais=listB.toArray(new AssertionInfo[]{}); assertTrue("Two different B instances should be added",ais[0].getAssertion() == nb && ais[1].getAssertion() == b || ais[0].getAssertion() == b && ais[1].getAssertion() == nb); Collection listC=aim.getAssertionInfo(new QName("http://x.y.z","c")); assertEquals("1 C assertion should've been added",1,listC.size()); ais=listC.toArray(new AssertionInfo[]{}); assertSame("One C instances should be added",ais[0].getAssertion(),c); }

Class: org.apache.cxf.ws.policy.EndpointPolicyImplTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testUpdatePolicy(){ EndpointPolicyImpl epi=new TestEndpointPolicy(); Policy p1=new Policy(); QName aqn1=new QName("http://x.y.z","a"); p1.addAssertion(mockAssertion(aqn1,5,true)); Policy p2=new Policy(); QName aqn2=new QName("http://x.y.z","b"); p2.addAssertion(mockAssertion(aqn2,5,true)); control.replay(); epi.setPolicy(p1.normalize(null,true)); Policy ep=epi.updatePolicy(p2,createMessage()).getPolicy(); List pops=CastUtils.cast(ep.getPolicyComponents(),ExactlyOne.class); assertEquals("New policy must have 1 top level policy operator",1,pops.size()); List alts=CastUtils.cast(pops.get(0).getPolicyComponents(),All.class); assertEquals("2 alternatives should be available",2,alts.size()); List assertions1=CastUtils.cast(alts.get(0).getAssertions(),PolicyAssertion.class); assertEquals("1 assertion should be available",1,assertions1.size()); List assertions2=CastUtils.cast(alts.get(1).getAssertions(),PolicyAssertion.class); assertEquals("1 assertion should be available",1,assertions2.size()); QName n1=assertions1.get(0).getName(); QName n2=assertions2.get(0).getName(); assertTrue("Policy was not merged",n1.equals(aqn1) && n2.equals(aqn2) || n1.equals(aqn2) && n2.equals(aqn1)); }

Class: org.apache.cxf.ws.policy.IgnorablePolicyInterceptorProviderTest

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testProvider(){ Bus bus=null; try { bus=new SpringBusFactory().createBus("/org/apache/cxf/ws/policy/ignorable-policy.xml",false); PolicyInterceptorProviderRegistry pipreg=bus.getExtension(PolicyInterceptorProviderRegistry.class); assertNotNull(pipreg); Set pips=pipreg.get(ONEWAY_QNAME); assertNotNull(pips); assertFalse(pips.isEmpty()); Set pips2=pipreg.get(DUPLEX_QNAME); assertNotNull(pips2); assertFalse(pips2.isEmpty()); assertEquals(pips.iterator().next(),pips2.iterator().next()); } finally { if (null != bus) { bus.shutdown(true); BusFactory.setDefaultBus(null); } } }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testTwoBuses(){ ClassPathXmlApplicationContext context=null; Bus cxf1=null; Bus cxf2=null; try { context=new ClassPathXmlApplicationContext("/org/apache/cxf/ws/policy/ignorable-policy2.xml"); cxf1=(Bus)context.getBean("cxf1"); assertNotNull(cxf1); cxf2=(Bus)context.getBean("cxf2"); assertNotNull(cxf2); PolicyInterceptorProviderRegistry pipreg1=cxf1.getExtension(PolicyInterceptorProviderRegistry.class); assertNotNull(pipreg1); PolicyInterceptorProviderRegistry pipreg2=cxf2.getExtension(PolicyInterceptorProviderRegistry.class); assertNotNull(pipreg2); Set pips1=pipreg1.get(ONEWAY_QNAME); assertNotNull(pips1); assertFalse(pips1.isEmpty()); Set pips2=pipreg2.get(ONEWAY_QNAME); assertNotNull(pips2); assertFalse(pips2.isEmpty()); assertEquals(pips1.iterator().next(),pips2.iterator().next()); context.close(); } finally { if (null != cxf1) { cxf1.shutdown(true); BusFactory.setDefaultBus(null); } } }

Class: org.apache.cxf.ws.policy.PolicyBuilderTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testGetPolicyReference() throws Exception { String name="/samples/test26.xml"; InputStream is=PolicyBuilderTest.class.getResourceAsStream(name); PolicyReference pr=builder.getPolicyReference(is); assertEquals("#PolicyA",pr.getURI()); name="/samples/test27.xml"; is=PolicyBuilderTest.class.getResourceAsStream(name); pr=builder.getPolicyReference(is); assertEquals("http://sample.org/test.wsdl#PolicyA",pr.getURI()); }

APIUtilityVerifier IterativeVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetPolicy() throws Exception { String name="/samples/test25.xml"; InputStream is=PolicyBuilderTest.class.getResourceAsStream(name); Policy p=builder.getPolicy(is); assertNotNull(p); List a=CastUtils.cast(p.getAssertions(),PolicyComponent.class); assertEquals(3,a.size()); for (int i=0; i < 3; i++) { assertEquals(Constants.TYPE_ASSERTION,a.get(i).getType()); } }

Class: org.apache.cxf.ws.policy.PolicyEngineImplInitTest

InternalCallVerifier EqualityVerifier 
@Test public void testPolicyInterceptors() throws Exception { Assert.assertEquals("should only have one PolicyOutInterceptor",bus.getOutInterceptors().size(),1); Assert.assertEquals("should only have one PolicyInInterceptor",bus.getInInterceptors().size(),1); }

Class: org.apache.cxf.ws.policy.PolicyEngineTest

BooleanVerifier InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testAddAssertions(){ engine=new PolicyEngineImpl(); Collection assertions=new ArrayList(); Assertion a=control.createMock(Assertion.class); EasyMock.expect(a.getType()).andReturn(Constants.TYPE_ASSERTION); EasyMock.expect(a.isOptional()).andReturn(true); control.replay(); engine.addAssertions(a,false,assertions); assertTrue(assertions.isEmpty()); control.verify(); control.reset(); EasyMock.expect(a.getType()).andReturn(Constants.TYPE_ASSERTION); control.replay(); engine.addAssertions(a,true,assertions); assertEquals(1,assertions.size()); assertSame(a,assertions.iterator().next()); control.verify(); assertions.clear(); Policy p=new Policy(); a=new PrimitiveAssertion(new QName("http://x.y.z","a")); p.addAssertion(a); engine.getRegistry().register("ab",p); PolicyReference pr=new PolicyReference(); pr.setURI("#ab"); engine.addAssertions(pr,false,assertions); assertEquals(1,assertions.size()); assertSame(a,assertions.iterator().next()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testGetAssertions() throws NoSuchMethodException { Method m=PolicyEngineImpl.class.getDeclaredMethod("addAssertions",new Class[]{PolicyComponent.class,boolean.class,Collection.class}); engine=EasyMock.createMockBuilder(PolicyEngineImpl.class).addMockedMethod(m).createMock(control); PolicyAssertion a=control.createMock(PolicyAssertion.class); EasyMock.expect(a.getType()).andReturn(Constants.TYPE_ASSERTION); EasyMock.expect(a.isOptional()).andReturn(true); control.replay(); assertTrue(engine.getAssertions(a,false).isEmpty()); control.verify(); control.reset(); EasyMock.expect(a.getType()).andReturn(Constants.TYPE_ASSERTION); control.replay(); Collection ca=engine.getAssertions(a,true); assertEquals(1,ca.size()); assertSame(a,ca.iterator().next()); control.verify(); control.reset(); Policy p=control.createMock(Policy.class); EasyMock.expect(p.getType()).andReturn(Constants.TYPE_POLICY); engine.addAssertions(EasyMock.eq(p),EasyMock.eq(false),CastUtils.cast(EasyMock.isA(Collection.class),Assertion.class)); EasyMock.expectLastCall(); control.replay(); assertTrue(engine.getAssertions(p,false).isEmpty()); control.verify(); }

Class: org.apache.cxf.ws.policy.PolicyExtensionsTest

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testExtensions(){ Bus bus=null; try { bus=new SpringBusFactory().createBus("/org/apache/cxf/ws/policy/policy-bus.xml",false); AssertionBuilderRegistry abr=bus.getExtension(AssertionBuilderRegistry.class); assertNotNull(abr); AssertionBuilder ab=abr.getBuilder(KNOWN); assertNotNull(ab); ab=abr.getBuilder(UNKNOWN); assertNull(ab); PolicyInterceptorProviderRegistry pipr=bus.getExtension(PolicyInterceptorProviderRegistry.class); assertNotNull(pipr); Set pips=pipr.get(KNOWN); assertNotNull(pips); assertFalse(pips.isEmpty()); pips=pipr.get(UNKNOWN); assertNotNull(pips); assertTrue(pips.isEmpty()); DomainExpressionBuilderRegistry debr=bus.getExtension(DomainExpressionBuilderRegistry.class); assertNotNull(debr); DomainExpressionBuilder deb=debr.get(KNOWN_DOMAIN_EXPR_TYPE); assertNotNull(deb); deb=debr.get(UNKNOWN); assertNull(deb); PolicyEngine pe=bus.getExtension(PolicyEngine.class); assertNotNull(pe); PolicyEngineImpl engine=(PolicyEngineImpl)pe; assertNotNull(engine.getPolicyProviders()); assertNotNull(engine.getRegistry()); Collection pps=engine.getPolicyProviders(); assertEquals(3,pps.size()); boolean wsdlProvider=false; boolean externalProvider=false; boolean serviceProvider=false; for ( PolicyProvider pp : pps) { if (pp instanceof Wsdl11AttachmentPolicyProvider) { wsdlProvider=true; } else if (pp instanceof ExternalAttachmentProvider) { externalProvider=true; } else if (pp instanceof ServiceModelPolicyProvider) { serviceProvider=true; } } assertTrue(wsdlProvider); assertTrue(externalProvider); assertTrue(serviceProvider); PolicyBuilder builder=bus.getExtension(PolicyBuilder.class); assertNotNull(builder); } finally { if (null != bus) { bus.shutdown(true); BusFactory.setDefaultBus(null); } } }

Class: org.apache.cxf.ws.policy.PolicyInterceptorProviderRegistryImplTest

EqualityVerifier NullVerifier HybridVerifier 
@Test public void testConstructors(){ PolicyInterceptorProviderRegistryImpl reg=new PolicyInterceptorProviderRegistryImpl(); assertNotNull(reg); assertEquals(PolicyInterceptorProviderRegistry.class,reg.getRegistrationType()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test @SuppressWarnings("unchecked") public void testRegister(){ PolicyInterceptorProviderRegistryImpl reg=new PolicyInterceptorProviderRegistryImpl(); PolicyInterceptorProvider pp=control.createMock(PolicyInterceptorProvider.class); Interceptor pi1=control.createMock(Interceptor.class); Interceptor pi2=control.createMock(Interceptor.class); Interceptor pif=control.createMock(Interceptor.class); Interceptor po=control.createMock(Interceptor.class); Interceptor pof=control.createMock(Interceptor.class); List> pil=new ArrayList>(); pil.add(pi1); pil.add(pi2); List> pifl=new ArrayList>(); pifl.add(pif); List> pol=new ArrayList>(); pol.add(po); List> pofl=new ArrayList>(); pofl.add(pof); EasyMock.expect(pp.getInInterceptors()).andReturn(pil); EasyMock.expect(pp.getInFaultInterceptors()).andReturn(pifl); EasyMock.expect(pp.getOutInterceptors()).andReturn(pol); EasyMock.expect(pp.getOutFaultInterceptors()).andReturn(pofl); Collection assertionTypes=new ArrayList(); assertionTypes.add(ASSERTION); EasyMock.expect(pp.getAssertionTypes()).andReturn(assertionTypes); control.replay(); reg.register(pp); assertEquals(pil,reg.getInInterceptorsForAssertion(ASSERTION)); assertEquals(pifl,reg.getInFaultInterceptorsForAssertion(ASSERTION)); assertEquals(pol,reg.getOutInterceptorsForAssertion(ASSERTION)); assertEquals(pofl,reg.getOutFaultInterceptorsForAssertion(ASSERTION)); assertTrue(reg.getInInterceptorsForAssertion(WRONG_ASSERTION).isEmpty()); control.verify(); }

Class: org.apache.cxf.ws.policy.attachment.external.DomainExpressionBuilderRegistryTest

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testNoBuilder(){ DomainExpressionBuilderRegistry reg=new DomainExpressionBuilderRegistry(); assertEquals(DomainExpressionBuilderRegistry.class,reg.getRegistrationType()); Element e=control.createMock(Element.class); EasyMock.expect(e.getNamespaceURI()).andReturn("http://a.b.c"); EasyMock.expect(e.getLocalName()).andReturn("x"); control.replay(); try { reg.build(e); fail("Expected PolicyException not thrown."); } catch ( PolicyException ex) { } control.verify(); }

Class: org.apache.cxf.ws.policy.attachment.external.ExternalAttachmentProviderTest

InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testReadDocumentEPRDomainExpression() throws MalformedURLException { Bus bus=control.createMock(Bus.class); DomainExpressionBuilderRegistry debr=control.createMock(DomainExpressionBuilderRegistry.class); EasyMock.expect(bus.getExtension(DomainExpressionBuilderRegistry.class)).andReturn(debr); DomainExpression de=control.createMock(DomainExpression.class); EasyMock.expect(debr.build(EasyMock.isA(Element.class))).andReturn(de); PolicyBuilder pb=control.createMock(PolicyBuilder.class); EasyMock.expect(bus.getExtension(PolicyBuilder.class)).andReturn(pb).anyTimes(); Policy p=control.createMock(Policy.class); EasyMock.expect(pb.getPolicy(EasyMock.isA(Element.class))).andReturn(p); control.replay(); ExternalAttachmentProvider eap=new ExternalAttachmentProvider(bus); URL url=ExternalAttachmentProviderTest.class.getResource("resources/attachments4.xml"); String uri=url.toExternalForm(); eap.setLocation(new UrlResource(uri)); eap.readDocument(); assertEquals(1,eap.getAttachments().size()); PolicyAttachment pa=eap.getAttachments().iterator().next(); assertSame(p,pa.getPolicy()); assertEquals(1,pa.getDomainExpressions().size()); assertSame(de,pa.getDomainExpressions().iterator().next()); control.verify(); }

Class: org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertionBuilderTest

InternalCallVerifier IdentityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetKnownElements() throws Exception { QName qn=new QName("http://cxf.apache.org/test/assertions/foo","FooType"); JaxbAssertionBuilder ab=new JaxbAssertionBuilder(FooType.class,qn); assertNotNull(ab); assertEquals(1,ab.getKnownElements().length); assertSame(qn,ab.getKnownElements()[0]); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBuild() throws Exception { QName qn=new QName("http://cxf.apache.org/test/assertions/foo","FooType"); JaxbAssertionBuilder ab=new JaxbAssertionBuilder(FooType.class,qn); assertNotNull(ab); InputStream is=JaxbAssertionBuilderTest.class.getResourceAsStream("foo.xml"); Document doc=StaxUtils.read(is); Element elem=DOMUtils.findAllElementsByTagNameNS(doc.getDocumentElement(),"http://cxf.apache.org/test/assertions/foo","foo").get(0); Assertion a=ab.build(elem,null); JaxbAssertion jba=JaxbAssertion.cast(a,FooType.class); FooType foo=jba.getData(); assertEquals("CXF",foo.getName()); assertEquals(2,foo.getNumber().intValue()); }

Class: org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertionTest

BooleanVerifier InternalCallVerifier IdentityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBasic(){ JaxbAssertion assertion=new JaxbAssertion(); assertNull(assertion.getName()); assertNull(assertion.getData()); assertTrue(!assertion.isOptional()); assertEquals(Constants.TYPE_ASSERTION,assertion.getType()); FooType data=new FooType(); data.setName("CXF"); data.setNumber(2); QName qn=new QName("http://cxf.apache.org/test/assertions/foo","FooType"); assertion.setName(qn); assertion.setData(data); assertion.setOptional(true); assertSame(qn,assertion.getName()); assertSame(data,assertion.getData()); assertTrue(assertion.isOptional()); assertEquals(Constants.TYPE_ASSERTION,assertion.getType()); }

APIUtilityVerifier IterativeVerifier BranchVerifier BooleanVerifier InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testNormalise(){ JaxbAssertion assertion=new JaxbAssertion(); FooType data=new FooType(); data.setName("CXF"); data.setNumber(2); QName qn=new QName("http://cxf.apache.org/test/assertions/foo","FooType"); assertion.setName(qn); assertion.setData(data); JaxbAssertion normalised=(JaxbAssertion)assertion.normalize(); assertTrue(normalised.equal(assertion)); assertSame(assertion.getData(),normalised.getData()); assertion.setOptional(true); PolicyComponent pc=assertion.normalize(); assertEquals(Constants.TYPE_POLICY,pc.getType()); Policy p=(Policy)pc; Iterator> alternatives=p.getAlternatives(); int total=0; for (int i=0; i < 2; i++) { List pcs=alternatives.next(); if (!pcs.isEmpty()) { assertTrue(assertion.equal(pcs.get(0))); total+=pcs.size(); } } assertTrue(!alternatives.hasNext()); assertEquals(1,total); }

Class: org.apache.cxf.ws.policy.selector.MinimalMaximalAlternativeSelectorTest

InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testChooseMaxAlternative(){ Message m=new MessageImpl(); AlternativeSelector selector=new MaximalAlternativeSelector(); PolicyEngine engine=control.createMock(PolicyEngine.class); Assertor assertor=control.createMock(Assertor.class); Policy policy=new Policy(); ExactlyOne ea=new ExactlyOne(); All all=new All(); PolicyAssertion a1=new TestAssertion(); all.addAssertion(a1); ea.addPolicyComponent(all); Collection maxAlternative=CastUtils.cast(all.getPolicyComponents(),PolicyAssertion.class); all=new All(); ea.addPolicyComponent(all); Collection minAlternative=CastUtils.cast(all.getPolicyComponents(),PolicyAssertion.class); policy.addPolicyComponent(ea); EasyMock.expect(engine.supportsAlternative(maxAlternative,assertor,m)).andReturn(true); EasyMock.expect(engine.supportsAlternative(minAlternative,assertor,m)).andReturn(true); control.replay(); Collection choice=selector.selectAlternative(policy,engine,assertor,null,m); assertEquals(1,choice.size()); assertSame(a1,choice.iterator().next()); control.verify(); }

InternalCallVerifier EqualityVerifier 
@Test public void testChooseMinAlternative(){ Message m=new MessageImpl(); AlternativeSelector selector=new MinimalAlternativeSelector(); PolicyEngine engine=control.createMock(PolicyEngine.class); Assertor assertor=control.createMock(Assertor.class); Policy policy=new Policy(); ExactlyOne ea=new ExactlyOne(); All all=new All(); PolicyAssertion a1=new TestAssertion(); all.addAssertion(a1); ea.addPolicyComponent(all); Collection maxAlternative=CastUtils.cast(all.getPolicyComponents(),PolicyAssertion.class); all=new All(); ea.addPolicyComponent(all); Collection minAlternative=CastUtils.cast(all.getPolicyComponents(),PolicyAssertion.class); policy.addPolicyComponent(ea); EasyMock.expect(engine.supportsAlternative(maxAlternative,assertor,m)).andReturn(true); EasyMock.expect(engine.supportsAlternative(minAlternative,assertor,m)).andReturn(true); control.replay(); Collection choice=selector.selectAlternative(policy,engine,assertor,null,m); assertEquals(0,choice.size()); control.verify(); }

Class: org.apache.cxf.ws.policy.spring.PolicyBeansTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testParse(){ Bus bus=new SpringBusFactory().createBus("org/apache/cxf/ws/policy/spring/beans.xml"); try { PolicyEngine pe=bus.getExtension(PolicyEngine.class); assertTrue("Policy engine is not enabled",pe.isEnabled()); assertTrue("Unknown assertions are not ignored",pe.isIgnoreUnknownAssertions()); assertEquals(MaximalAlternativeSelector.class.getName(),pe.getAlternativeSelector().getClass().getName()); PolicyEngineImpl pei=(PolicyEngineImpl)pe; Collection providers=pei.getPolicyProviders(); assertEquals(4,providers.size()); int n=0; for ( PolicyProvider pp : providers) { if (pp instanceof ExternalAttachmentProvider) { n++; } } assertEquals("Unexpected number of external providers",2,n); } finally { bus.shutdown(true); } }

Class: org.apache.cxf.ws.rm.AbstractRMInterceptorTest

InternalCallVerifier IdentityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testAccessors(){ RMInterceptor interceptor=new RMInterceptor(); assertEquals(Phase.PRE_LOGICAL,interceptor.getPhase()); Bus bus=control.createMock(Bus.class); RMManager busMgr=control.createMock(RMManager.class); EasyMock.expect(bus.getExtension(RMManager.class)).andReturn(busMgr); RMManager mgr=control.createMock(RMManager.class); control.replay(); assertNull(interceptor.getBus()); interceptor.setBus(bus); assertSame(bus,interceptor.getBus()); assertSame(busMgr,interceptor.getManager()); interceptor.setManager(mgr); assertSame(mgr,interceptor.getManager()); }

Class: org.apache.cxf.ws.rm.DestinationSequenceTest

InternalCallVerifier IdentityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testConstructors(){ Identifier otherId=factory.createIdentifier(); otherId.setValue("otherSeq"); DestinationSequence seq=new DestinationSequence(id,ref,destination,ProtocolVariation.RM10WSA200408); assertEquals(id,seq.getIdentifier()); assertEquals(0,seq.getLastMessageNumber()); assertSame(ref,seq.getAcksTo()); assertNotNull(seq.getAcknowledgment()); assertNotNull(seq.getMonitor()); SequenceAcknowledgement ack=new SequenceAcknowledgement(); seq=new DestinationSequence(id,ref,10,ack,ProtocolVariation.RM10WSA200408); assertEquals(id,seq.getIdentifier()); assertEquals(10,seq.getLastMessageNumber()); assertSame(ref,seq.getAcksTo()); assertSame(ack,seq.getAcknowledgment()); assertNotNull(seq.getMonitor()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testMerge(){ DestinationSequence seq=new DestinationSequence(id,ref,destination,ProtocolVariation.RM10WSA200408); List ranges=seq.getAcknowledgment().getAcknowledgementRange(); AcknowledgementRange r; for (int i=0; i < 5; i++) { r=new AcknowledgementRange(); r.setLower(new Long(3 * i + 1)); r.setUpper(new Long(3 * i + 3)); ranges.add(r); } seq.mergeRanges(); assertEquals(1,ranges.size()); r=ranges.get(0); assertEquals(new Long(1),r.getLower()); assertEquals(new Long(15),r.getUpper()); ranges.clear(); for (int i=0; i < 5; i++) { r=new AcknowledgementRange(); r.setLower(new Long(3 * i + 1)); r.setUpper(new Long(3 * i + 2)); ranges.add(r); } seq.mergeRanges(); assertEquals(5,ranges.size()); ranges.clear(); for (int i=0; i < 5; i++) { if (i != 2) { r=new AcknowledgementRange(); r.setLower(new Long(3 * i + 1)); r.setUpper(new Long(3 * i + 3)); ranges.add(r); } } seq.mergeRanges(); assertEquals(2,ranges.size()); r=ranges.get(0); assertEquals(new Long(1),r.getLower()); assertEquals(new Long(6),r.getUpper()); r=ranges.get(1); assertEquals(new Long(10),r.getLower()); assertEquals(new Long(15),r.getUpper()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCorrelationID(){ setUpDestination(); DestinationSequence seq=new DestinationSequence(id,ref,destination,ProtocolVariation.RM10WSA200408); String correlationID="abdc1234"; assertNull("unexpected correlation ID",seq.getCorrelationID()); seq.setCorrelationID(correlationID); assertEquals("unexpected correlation ID",correlationID,seq.getCorrelationID()); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testMonitor() throws SequenceFault { Timer timer=control.createMock(Timer.class); setUpDestination(timer,null); Message[] messages=new Message[15]; for (int i=0; i < messages.length; i++) { messages[i]=setUpMessage(Integer.toString(i + 1)); } control.replay(); DestinationSequence seq=new DestinationSequence(id,ref,destination,ProtocolVariation.RM10WSA200408); SequenceMonitor monitor=seq.getMonitor(); assertNotNull(monitor); monitor.setMonitorInterval(500); assertEquals(0,monitor.getMPM()); for (int i=0; i < 10; i++) { seq.acknowledge(messages[i]); try { Thread.sleep(55); } catch ( InterruptedException ex) { } } int mpm1=monitor.getMPM(); assertTrue("unexpected MPM: " + mpm1,mpm1 > 0); for (int i=10; i < messages.length; i++) { seq.acknowledge(messages[i]); try { Thread.sleep(110); } catch ( InterruptedException ex) { } } int mpm2=monitor.getMPM(); assertTrue(mpm2 > 0); assertTrue(mpm1 > mpm2); control.verify(); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testAcknowledgeAppendRange() throws SequenceFault { Timer timer=control.createMock(Timer.class); setUpDestination(timer,null); Message[] messages=new Message[]{setUpMessage("1"),setUpMessage("2"),setUpMessage("5"),setUpMessage("4"),setUpMessage("6")}; control.replay(); DestinationSequence seq=new DestinationSequence(id,ref,destination,ProtocolVariation.RM10WSA200408); List ranges=seq.getAcknowledgment().getAcknowledgementRange(); for (int i=0; i < messages.length; i++) { seq.acknowledge(messages[i]); } assertEquals(2,ranges.size()); AcknowledgementRange r=ranges.get(0); assertEquals(1,r.getLower().intValue()); assertEquals(2,r.getUpper().intValue()); r=ranges.get(1); assertEquals(4,r.getLower().intValue()); assertEquals(6,r.getUpper().intValue()); control.verify(); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testAcknowledgeBasic() throws SequenceFault { Timer timer=control.createMock(Timer.class); setUpDestination(timer,null); Message message1=setUpMessage("1"); Message message2=setUpMessage("2"); control.replay(); DestinationSequence seq=new DestinationSequence(id,ref,destination,ProtocolVariation.RM10WSA200408); List ranges=seq.getAcknowledgment().getAcknowledgementRange(); assertEquals(0,ranges.size()); seq.acknowledge(message1); assertEquals(1,ranges.size()); AcknowledgementRange r1=ranges.get(0); assertEquals(1,r1.getLower().intValue()); assertEquals(1,r1.getUpper().intValue()); seq.acknowledge(message2); assertEquals(1,ranges.size()); r1=ranges.get(0); assertEquals(1,r1.getLower().intValue()); assertEquals(2,r1.getUpper().intValue()); control.verify(); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testAcknowledgeInsertRange() throws SequenceFault { Timer timer=control.createMock(Timer.class); setUpDestination(timer,null); Message[] messages=new Message[]{setUpMessage("1"),setUpMessage("2"),setUpMessage("9"),setUpMessage("10"),setUpMessage("4"),setUpMessage("9"),setUpMessage("2")}; control.replay(); DestinationSequence seq=new DestinationSequence(id,ref,destination,ProtocolVariation.RM10WSA200408); List ranges=seq.getAcknowledgment().getAcknowledgementRange(); for (int i=0; i < messages.length; i++) { seq.acknowledge(messages[i]); } assertEquals(3,ranges.size()); AcknowledgementRange r=ranges.get(0); assertEquals(1,r.getLower().intValue()); assertEquals(2,r.getUpper().intValue()); r=ranges.get(1); assertEquals(4,r.getLower().intValue()); assertEquals(4,r.getUpper().intValue()); r=ranges.get(2); assertEquals(9,r.getLower().intValue()); assertEquals(10,r.getUpper().intValue()); control.verify(); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetEndpointIdentifier(){ setUpDestination(); String name="abc"; EasyMock.expect(destination.getName()).andReturn(name); control.replay(); DestinationSequence seq=new DestinationSequence(id,ref,destination,ProtocolVariation.RM10WSA200408); assertEquals("Unexpected endpoint identifier",name,seq.getEndpointIdentifier()); control.verify(); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testEqualsAndHashCode(){ DestinationSequence seq=new DestinationSequence(id,ref,destination,ProtocolVariation.RM10WSA200408); DestinationSequence otherSeq=null; assertTrue(!seq.equals(otherSeq)); otherSeq=new DestinationSequence(id,ref,destination,ProtocolVariation.RM10WSA200408); assertEquals(seq,otherSeq); assertEquals(seq.hashCode(),otherSeq.hashCode()); Identifier otherId=factory.createIdentifier(); otherId.setValue("otherSeq"); otherSeq=new DestinationSequence(otherId,ref,destination,ProtocolVariation.RM10WSA200408); assertTrue(!seq.equals(otherSeq)); assertTrue(seq.hashCode() != otherSeq.hashCode()); assertTrue(!seq.equals(this)); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testAcknowledgePrependRange() throws SequenceFault { Timer timer=control.createMock(Timer.class); setUpDestination(timer,null); Message[] messages=new Message[]{setUpMessage("4"),setUpMessage("5"),setUpMessage("6"),setUpMessage("4"),setUpMessage("2"),setUpMessage("2")}; control.replay(); DestinationSequence seq=new DestinationSequence(id,ref,destination,ProtocolVariation.RM10WSA200408); List ranges=seq.getAcknowledgment().getAcknowledgementRange(); for (int i=0; i < messages.length; i++) { seq.acknowledge(messages[i]); } assertEquals(2,ranges.size()); AcknowledgementRange r=ranges.get(0); assertEquals(2,r.getLower().intValue()); assertEquals(2,r.getUpper().intValue()); r=ranges.get(1); assertEquals(4,r.getLower().intValue()); assertEquals(6,r.getUpper().intValue()); control.verify(); }

Class: org.apache.cxf.ws.rm.DestinationTest

EqualityVerifier 
@Test public void testGetAllSequences(){ control.replay(); assertEquals(0,destination.getAllSequences().size()); }

InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testAddRemoveSequence(){ DestinationSequence ds=control.createMock(DestinationSequence.class); ds.setDestination(destination); EasyMock.expectLastCall(); Identifier id=control.createMock(Identifier.class); EasyMock.expect(ds.getIdentifier()).andReturn(id).times(3); String sid="s1"; EasyMock.expect(id.getValue()).andReturn(sid).times(3); RMManager manager=control.createMock(RMManager.class); EasyMock.expect(rme.getManager()).andReturn(manager).times(2); RMStore store=control.createMock(RMStore.class); EasyMock.expect(manager.getStore()).andReturn(store).times(2); store.createDestinationSequence(ds); EasyMock.expectLastCall(); store.removeDestinationSequence(id); EasyMock.expectLastCall(); control.replay(); destination.addSequence(ds); assertEquals(1,destination.getAllSequences().size()); assertSame(ds,destination.getSequence(id)); destination.removeSequence(ds); assertEquals(0,destination.getAllSequences().size()); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testAcknowledgeUnknownSequence() throws RMException, IOException { Message message=setupMessage(); RMProperties rmps=control.createMock(RMProperties.class); EasyMock.expect(message.get(RMMessageConstants.RM_PROPERTIES_INBOUND)).andReturn(rmps); EasyMock.expect(RMContextUtils.getProtocolVariation(message)).andReturn(ProtocolVariation.RM10WSA200408); SequenceType st=control.createMock(SequenceType.class); EasyMock.expect(rmps.getSequence()).andReturn(st); Identifier id=control.createMock(Identifier.class); EasyMock.expect(st.getIdentifier()).andReturn(id).times(2); String sid="sid"; EasyMock.expect(id.getValue()).andReturn(sid); control.replay(); try { destination.acknowledge(message); fail("Expected SequenceFault not thrown."); } catch ( SequenceFault ex) { assertEquals(RM10Constants.UNKNOWN_SEQUENCE_FAULT_QNAME,ex.getFaultCode()); } }

Class: org.apache.cxf.ws.rm.ManagedRMManagerTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testGetSourceSequenceAcknowledgedRange() throws Exception { ManagedRMEndpoint managedEndpoint=createTestManagedRMEndpoint(); Long[] ranges=managedEndpoint.getSourceSequenceAcknowledgedRange("seq1"); assertEquals(4,ranges.length); assertTrue(1L == ranges[0] && 1L == ranges[1] && 3L == ranges[2] && 3L == ranges[3]); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testGetUnAcknowledgedMessageIdentifiers() throws Exception { ManagedRMEndpoint managedEndpoint=createTestManagedRMEndpoint(); Long[] numbers=managedEndpoint.getUnAcknowledgedMessageIdentifiers("seq1"); assertEquals(2,numbers.length); assertTrue(2L == numbers[0] && 4L == numbers[1]); }

InternalCallVerifier EqualityVerifier 
@Test public void testManagedRMEndpointGetQueuedCount() throws Exception { ManagedRMEndpoint managedEndpoint=createTestManagedRMEndpoint(); int n=managedEndpoint.getQueuedMessageTotalCount(true); assertEquals(3,n); n=managedEndpoint.getQueuedMessageCount("seq1",true); assertEquals(2,n); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testManagedRMManager() throws Exception { final SpringBusFactory factory=new SpringBusFactory(); bus=factory.createBus("org/apache/cxf/ws/rm/managed-manager-bean.xml"); im=bus.getExtension(InstrumentationManager.class); manager=bus.getExtension(RMManager.class); endpoint=createTestEndpoint(); assertTrue("Instrumentation Manager should not be null",im != null); assertTrue("RMManager should not be null",manager != null); MBeanServer mbs=im.getMBeanServer(); assertNotNull("MBeanServer should be available.",mbs); ObjectName managerName=RMUtils.getManagedObjectName(manager); Set mbset=mbs.queryMBeans(managerName,null); assertEquals("ManagedRMManager should be found",1,mbset.size()); Object o; o=mbs.getAttribute(managerName,"UsingStore"); assertTrue(o instanceof Boolean); assertFalse("Store attribute is false",(Boolean)o); o=mbs.invoke(managerName,"getEndpointIdentifiers",null,null); assertTrue(o instanceof String[]); assertEquals("No Endpoint",0,((String[])o).length); RMEndpoint rme=createTestRMEndpoint(); ObjectName endpointName=RMUtils.getManagedObjectName(rme); mbset=mbs.queryMBeans(endpointName,null); assertEquals("ManagedRMEndpoint should be found",1,mbset.size()); o=mbs.invoke(managerName,"getEndpointIdentifiers",null,null); assertEquals("One Endpoint",1,((String[])o).length); assertEquals("Endpoint identifier must match",RMUtils.getEndpointIdentifier(endpoint,bus),((String[])o)[0]); o=mbs.getAttribute(endpointName,"Address"); assertTrue(o instanceof String); assertEquals("Endpoint address must match",TEST_URI,o); o=mbs.getAttribute(endpointName,"LastApplicationMessage"); assertNull(o); o=mbs.getAttribute(endpointName,"LastControlMessage"); assertNull(o); o=mbs.invoke(endpointName,"getDestinationSequenceIds",null,null); assertTrue(o instanceof String[]); assertEquals("No sequence",0,((String[])o).length); o=mbs.invoke(endpointName,"getDestinationSequences",null,null); assertTrue(o instanceof CompositeData[]); assertEquals("No sequence",0,((CompositeData[])o).length); o=mbs.invoke(endpointName,"getSourceSequenceIds",new Object[]{true},new String[]{"boolean"}); assertTrue(o instanceof String[]); assertEquals("No sequence",0,((String[])o).length); o=mbs.invoke(endpointName,"getSourceSequences",new Object[]{true},new String[]{"boolean"}); assertTrue(o instanceof CompositeData[]); assertEquals("No sequence",0,((CompositeData[])o).length); o=mbs.invoke(endpointName,"getDeferredAcknowledgementTotalCount",null,null); assertTrue(o instanceof Integer); assertEquals("No deferred acks",0,o); o=mbs.invoke(endpointName,"getQueuedMessageTotalCount",new Object[]{true},new String[]{"boolean"}); assertTrue(o instanceof Integer); assertEquals("No queued messages",0,o); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testGetDestinationSequences() throws Exception { ManagedRMEndpoint managedEndpoint=createTestManagedRMEndpoint(); String[] sids=managedEndpoint.getDestinationSequenceIds(); assertEquals(2,sids.length); assertTrue(("seq3".equals(sids[0]) || "seq3".equals(sids[1])) && ("seq4".equals(sids[0]) || "seq4".equals(sids[1]))); CompositeData[] sequences=managedEndpoint.getDestinationSequences(); assertEquals(2,sequences.length); verifyDestinationSequence(sequences[0]); verifyDestinationSequence(sequences[1]); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testGetSourceSequences() throws Exception { ManagedRMEndpoint managedEndpoint=createTestManagedRMEndpoint(); String[] sids=managedEndpoint.getSourceSequenceIds(true); assertEquals(2,sids.length); assertTrue(("seq1".equals(sids[0]) || "seq1".equals(sids[1])) && ("seq2".equals(sids[0]) || "seq2".equals(sids[1]))); String sid=managedEndpoint.getCurrentSourceSequenceId(); assertEquals("seq2",sid); CompositeData[] sequences=managedEndpoint.getSourceSequences(true); assertEquals(2,sequences.length); verifySourceSequence(sequences[0]); verifySourceSequence(sequences[1]); }

Class: org.apache.cxf.ws.rm.ProxyTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testInvoke() throws Exception { Method m=Proxy.class.getDeclaredMethod("createClient",new Class[]{Bus.class,Endpoint.class,ProtocolVariation.class,Conduit.class,org.apache.cxf.ws.addressing.EndpointReferenceType.class}); Proxy proxy=EasyMock.createMockBuilder(Proxy.class).addMockedMethod(m).createMock(control); proxy.setReliableEndpoint(rme); RMManager manager=control.createMock(RMManager.class); EasyMock.expect(rme.getManager()).andReturn(manager).anyTimes(); Bus bus=control.createMock(Bus.class); EasyMock.expect(manager.getBus()).andReturn(bus).anyTimes(); Endpoint endpoint=control.createMock(Endpoint.class); EasyMock.expect(rme.getEndpoint(ProtocolVariation.RM10WSA200408)).andReturn(endpoint).anyTimes(); BindingInfo bi=control.createMock(BindingInfo.class); EasyMock.expect(rme.getBindingInfo(ProtocolVariation.RM10WSA200408)).andReturn(bi).anyTimes(); Conduit conduit=control.createMock(Conduit.class); EasyMock.expect(rme.getConduit()).andReturn(conduit).anyTimes(); org.apache.cxf.ws.addressing.EndpointReferenceType replyTo=control.createMock(org.apache.cxf.ws.addressing.EndpointReferenceType.class); EasyMock.expect(rme.getReplyTo()).andReturn(replyTo).anyTimes(); OperationInfo oi=control.createMock(OperationInfo.class); BindingOperationInfo boi=control.createMock(BindingOperationInfo.class); EasyMock.expect(bi.getOperation(oi)).andReturn(boi).anyTimes(); Client client=control.createMock(Client.class); EasyMock.expect(client.getRequestContext()).andReturn(new HashMap()).anyTimes(); EasyMock.expect(proxy.createClient(bus,endpoint,ProtocolVariation.RM10WSA200408,conduit,replyTo)).andReturn(client).anyTimes(); Object[] args=new Object[]{}; Map context=new HashMap(); Object[] results=new Object[]{"a","b","c"}; Exchange exchange=control.createMock(Exchange.class); EasyMock.expect(client.invoke(boi,args,context,exchange)).andReturn(results).anyTimes(); control.replay(); assertEquals("a",proxy.invoke(oi,ProtocolVariation.RM10WSA200408,args,context,exchange)); }

Class: org.apache.cxf.ws.rm.RMEndpointTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testMessageArrivals(){ assertEquals(0L,rme.getLastApplicationMessage()); assertEquals(0L,rme.getLastControlMessage()); rme.receivedControlMessage(); assertEquals(0L,rme.getLastApplicationMessage()); assertTrue(rme.getLastControlMessage() > 0); rme.receivedApplicationMessage(); assertTrue(rme.getLastApplicationMessage() > 0); assertTrue(rme.getLastControlMessage() > 0); control.replay(); }

APIUtilityVerifier InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testCreateEndpoint() throws NoSuchMethodException, EndpointException { Method m=RMEndpoint.class.getDeclaredMethod("getUsingAddressing",new Class[]{EndpointInfo.class}); Service as=control.createMock(Service.class); EndpointInfo aei=new EndpointInfo(); ae=new EndpointImpl(null,as,aei); rme=EasyMock.createMockBuilder(RMEndpoint.class).withConstructor(manager,ae).addMockedMethod(m).createMock(control); rme.setAplicationEndpoint(ae); rme.setManager(manager); SoapBindingInfo bi=control.createMock(SoapBindingInfo.class); aei.setBinding(bi); SoapVersion sv=Soap11.getInstance(); EasyMock.expect(bi.getSoapVersion()).andReturn(sv); String ns="http://schemas.xmlsoap.org/wsdl/soap/"; EasyMock.expect(bi.getBindingId()).andReturn(ns); aei.setTransportId(ns); String addr="addr"; aei.setAddress(addr); Object ua=new Object(); EasyMock.expect(rme.getUsingAddressing(aei)).andReturn(ua); control.replay(); rme.createServices(); rme.createEndpoints(null); Endpoint e=rme.getEndpoint(ProtocolVariation.RM10WSA200408); WrappedEndpoint we=(WrappedEndpoint)e; assertSame(ae,we.getWrappedEndpoint()); Service s=rme.getService(ProtocolVariation.RM10WSA200408); assertEquals(1,s.getEndpoints().size()); assertSame(e,s.getEndpoints().get(RM10Constants.PORT_NAME)); }

Class: org.apache.cxf.ws.rm.RMInInterceptorTest

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testProcessAcknowledgments() throws RMException { interceptor=new RMInInterceptor(); manager=control.createMock(RMManager.class); Source source=control.createMock(Source.class); rme=control.createMock(RMEndpoint.class); EasyMock.expect(rme.getSource()).andReturn(source).anyTimes(); interceptor.setManager(manager); SequenceAcknowledgement ack1=control.createMock(SequenceAcknowledgement.class); SequenceAcknowledgement ack2=control.createMock(SequenceAcknowledgement.class); Collection acks=new ArrayList(); acks.add(ack1); acks.add(ack2); EasyMock.expect(rmps.getAcks()).andReturn(acks); Identifier id1=control.createMock(Identifier.class); EasyMock.expect(ack1.getIdentifier()).andReturn(id1); SourceSequence ss1=control.createMock(SourceSequence.class); EasyMock.expect(source.getSequence(id1)).andReturn(ss1); ss1.setAcknowledged(ack1); EasyMock.expectLastCall(); Identifier id2=control.createMock(Identifier.class); EasyMock.expect(ack2.getIdentifier()).andReturn(id2); EasyMock.expect(source.getSequence(id2)).andReturn(null); control.replay(); try { interceptor.processAcknowledgments(rme,rmps,ProtocolVariation.RM10WSA200408); fail("Expected SequenceFault not thrown"); } catch ( SequenceFault sf) { assertEquals(RM10Constants.UNKNOWN_SEQUENCE_FAULT_QNAME,sf.getFaultCode()); } }

Class: org.apache.cxf.ws.rm.RMManagerConfigurationTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testExactlyOnce(){ SpringBusFactory factory=new SpringBusFactory(); bus=factory.createBus("org/apache/cxf/ws/rm/exactly-once.xml",false); RMManager manager=bus.getExtension(RMManager.class); RMConfiguration cfg=manager.getConfiguration(); DeliveryAssurance da=cfg.getDeliveryAssurance(); assertEquals(da,DeliveryAssurance.EXACTLY_ONCE); assertFalse(cfg.isInOrder()); }

Class: org.apache.cxf.ws.rm.RMManagerTest

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCustom(){ Bus bus=new SpringBusFactory().createBus("org/apache/cxf/ws/rm/custom-rmmanager.xml",false); manager=bus.getExtension(RMManager.class); assertNotNull("sourcePolicy is not set.",manager.getSourcePolicy()); assertNotNull("destinationPolicy is not set.",manager.getDestinationPolicy()); manager.initialise(); RMConfiguration cfg=manager.getConfiguration(); assertNotNull("RMConfiguration is not set.",cfg); assertNotNull("deliveryAssurance is not set.",cfg.getDeliveryAssurance()); assertFalse(cfg.isExponentialBackoff()); assertEquals(10000L,cfg.getBaseRetransmissionInterval().longValue()); assertEquals(10000L,cfg.getAcknowledgementIntervalTime()); assertNull(cfg.getInactivityTimeout()); SourcePolicyType sp=manager.getSourcePolicy(); assertEquals(0L,sp.getSequenceExpiration().getTimeInMillis(new Date())); assertEquals(0L,sp.getOfferedSequenceExpiration().getTimeInMillis(new Date())); assertNull(sp.getAcksTo()); assertTrue(sp.isIncludeOffer()); SequenceTerminationPolicyType stp=sp.getSequenceTerminationPolicy(); assertEquals(0,stp.getMaxRanges()); assertEquals(0,stp.getMaxUnacknowledged()); assertFalse(stp.isTerminateOnShutdown()); assertEquals(0,stp.getMaxLength()); DestinationPolicyType dp=manager.getDestinationPolicy(); assertNotNull(dp.getAcksPolicy()); assertEquals(dp.getAcksPolicy().getIntraMessageThreshold(),0); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testInitialisation(){ manager=new RMManager(); assertNull("sourcePolicy is set.",manager.getSourcePolicy()); assertNull("destinationPolicy is set.",manager.getDestinationPolicy()); manager.initialise(); RMConfiguration cfg=manager.getConfiguration(); assertNotNull("RMConfiguration is not set.",cfg); assertNotNull("sourcePolicy is not set.",manager.getSourcePolicy()); assertNotNull("destinationPolicy is not set.",manager.getDestinationPolicy()); assertNotNull("deliveryAssirance is not set.",cfg.getDeliveryAssurance()); assertTrue(cfg.isExponentialBackoff()); assertEquals(3000L,cfg.getBaseRetransmissionInterval().longValue()); assertNull(cfg.getAcknowledgementInterval()); assertNull(cfg.getInactivityTimeout()); SourcePolicyType sp=manager.getSourcePolicy(); assertEquals(0L,sp.getSequenceExpiration().getTimeInMillis(new Date())); assertEquals(0L,sp.getOfferedSequenceExpiration().getTimeInMillis(new Date())); assertNull(sp.getAcksTo()); assertTrue(sp.isIncludeOffer()); SequenceTerminationPolicyType stp=sp.getSequenceTerminationPolicy(); assertEquals(0,stp.getMaxRanges()); assertEquals(0,stp.getMaxUnacknowledged()); assertTrue(stp.isTerminateOnShutdown()); assertEquals(0,stp.getMaxLength()); DestinationPolicyType dp=manager.getDestinationPolicy(); assertNotNull(dp.getAcksPolicy()); assertEquals(dp.getAcksPolicy().getIntraMessageThreshold(),10); }

Class: org.apache.cxf.ws.rm.RMUtilsTest

InternalCallVerifier EqualityVerifier 
@Test public void testGetName(){ Endpoint e=control.createMock(Endpoint.class); EndpointInfo ei=control.createMock(EndpointInfo.class); EasyMock.expect(e.getEndpointInfo()).andReturn(ei).times(2); QName eqn=new QName("ns2","endpoint"); EasyMock.expect(ei.getName()).andReturn(eqn); ServiceInfo si=control.createMock(ServiceInfo.class); EasyMock.expect(ei.getService()).andReturn(si); QName sqn=new QName("ns1","service"); EasyMock.expect(si.getName()).andReturn(sqn); control.replay(); assertEquals("{ns1}service.{ns2}endpoint@" + Bus.DEFAULT_BUS_ID,RMUtils.getEndpointIdentifier(e)); control.reset(); EasyMock.expect(e.getEndpointInfo()).andReturn(ei).times(2); EasyMock.expect(ei.getName()).andReturn(eqn); EasyMock.expect(ei.getService()).andReturn(si); EasyMock.expect(si.getName()).andReturn(sqn); Bus b=control.createMock(Bus.class); EasyMock.expect(b.getId()).andReturn("mybus"); control.replay(); assertEquals("{ns1}service.{ns2}endpoint@mybus",RMUtils.getEndpointIdentifier(e,b)); control.reset(); EasyMock.expect(e.getEndpointInfo()).andReturn(ei).times(2); EasyMock.expect(ei.getName()).andReturn(eqn); EasyMock.expect(ei.getService()).andReturn(si); EasyMock.expect(si.getName()).andReturn(sqn); control.replay(); Bus bus=BusFactory.getDefaultBus(); assertEquals("{ns1}service.{ns2}endpoint@" + Bus.DEFAULT_BUS_ID,RMUtils.getEndpointIdentifier(e,bus)); bus.shutdown(true); control.reset(); EasyMock.expect(e.getEndpointInfo()).andReturn(ei).times(2); EasyMock.expect(ei.getName()).andReturn(eqn); EasyMock.expect(ei.getService()).andReturn(si); EasyMock.expect(si.getName()).andReturn(sqn); EasyMock.expect(b.getId()).andReturn("mybus-" + Bus.DEFAULT_BUS_ID + "12345"); control.replay(); assertEquals("{ns1}service.{ns2}endpoint@mybus-" + Bus.DEFAULT_BUS_ID,RMUtils.getEndpointIdentifier(e,b)); control.reset(); EasyMock.expect(e.getEndpointInfo()).andReturn(ei).times(2); EasyMock.expect(ei.getName()).andReturn(eqn); EasyMock.expect(ei.getService()).andReturn(si); EasyMock.expect(si.getName()).andReturn(sqn); EasyMock.expect(b.getId()).andReturn("mybus." + Bus.DEFAULT_BUS_ID + ".foo"); control.replay(); assertEquals("{ns1}service.{ns2}endpoint@mybus." + Bus.DEFAULT_BUS_ID + ".foo",RMUtils.getEndpointIdentifier(e,b)); }

Class: org.apache.cxf.ws.rm.SourceSequenceTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testEqualsAndHashCode(){ SourceSequence seq=new SourceSequence(id,ProtocolVariation.RM10WSA200408); SourceSequence otherSeq=null; assertTrue(!seq.equals(otherSeq)); otherSeq=new SourceSequence(id,ProtocolVariation.RM10WSA200408); assertEquals(seq,otherSeq); assertEquals(seq.hashCode(),otherSeq.hashCode()); Identifier otherId=factory.createIdentifier(); otherId.setValue("otherSeq"); otherSeq=new SourceSequence(otherId,ProtocolVariation.RM10WSA200408); assertTrue(!seq.equals(otherSeq)); assertTrue(seq.hashCode() != otherSeq.hashCode()); assertTrue(!seq.equals(this)); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testNextMessageNumber() throws RMException { SourceSequence seq=null; setUpSource(); rq.purgeAcknowledged(EasyMock.isA(SourceSequence.class)); EasyMock.expectLastCall().anyTimes(); control.replay(); seq=new SourceSequence(id,ProtocolVariation.RM10WSA200408); seq.setSource(source); assertTrue(!nextMessages(seq,10)); control.verify(); seq=new SourceSequence(id,ProtocolVariation.RM10WSA200408); seq.setSource(source); stp.setMaxLength(1); assertTrue(nextMessages(seq,10)); assertEquals(1,seq.getCurrentMessageNr()); control.verify(); seq=new SourceSequence(id,ProtocolVariation.RM10WSA200408); seq.setSource(source); stp.setMaxLength(5); assertTrue(!nextMessages(seq,2)); control.verify(); seq=new SourceSequence(id,ProtocolVariation.RM10WSA200408); seq.setSource(source); stp.setMaxLength(0); stp.setMaxRanges(3); acknowledge(seq,1,2,4,5,6,8,9,10); assertTrue(nextMessages(seq,10)); assertEquals(1,seq.getCurrentMessageNr()); control.verify(); seq=new SourceSequence(id,ProtocolVariation.RM10WSA200408); seq.setSource(source); stp.setMaxLength(0); stp.setMaxRanges(4); acknowledge(seq,1,2,4,5,6,8,9,10); assertTrue(!nextMessages(seq,10)); control.verify(); }

BooleanVerifier InternalCallVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testSetAcknowledged() throws RMException { SourceSequence seq=new SourceSequence(id,ProtocolVariation.RM10WSA200408); setUpSource(); seq.setSource(source); SequenceAcknowledgement ack=seq.getAcknowledgement(); ack=factory.createSequenceAcknowledgement(); SequenceAcknowledgement.AcknowledgementRange r=factory.createSequenceAcknowledgementAcknowledgementRange(); r.setLower(new Long(1)); r.setUpper(new Long(2)); ack.getAcknowledgementRange().add(r); r=factory.createSequenceAcknowledgementAcknowledgementRange(); r.setLower(new Long(4)); r.setUpper(new Long(6)); ack.getAcknowledgementRange().add(r); r=factory.createSequenceAcknowledgementAcknowledgementRange(); r.setLower(new Long(8)); r.setUpper(new Long(10)); ack.getAcknowledgementRange().add(r); rq.purgeAcknowledged(seq); EasyMock.expectLastCall(); control.replay(); seq.setAcknowledged(ack); assertSame(ack,seq.getAcknowledgement()); assertEquals(3,ack.getAcknowledgementRange().size()); assertTrue(!seq.isAcknowledged(3)); assertTrue(seq.isAcknowledged(5)); control.verify(); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testConstructors(){ Identifier otherId=factory.createIdentifier(); otherId.setValue("otherSeq"); SourceSequence seq=null; seq=new SourceSequence(id,ProtocolVariation.RM10WSA200408); assertEquals(id,seq.getIdentifier()); assertTrue(!seq.isLastMessage()); assertTrue(!seq.isExpired()); assertEquals(0,seq.getCurrentMessageNr()); assertNotNull(seq.getAcknowledgement()); assertEquals(0,seq.getAcknowledgement().getAcknowledgementRange().size()); assertTrue(!seq.allAcknowledged()); assertFalse(seq.offeredBy(otherId)); Date expiry=new Date(System.currentTimeMillis() + 3600 * 1000); seq=new SourceSequence(id,expiry,null,ProtocolVariation.RM10WSA200408); assertEquals(id,seq.getIdentifier()); assertTrue(!seq.isLastMessage()); assertTrue(!seq.isExpired()); assertEquals(0,seq.getCurrentMessageNr()); assertNotNull(seq.getAcknowledgement()); assertEquals(0,seq.getAcknowledgement().getAcknowledgementRange().size()); assertTrue(!seq.allAcknowledged()); assertFalse(seq.offeredBy(otherId)); seq=new SourceSequence(id,expiry,otherId,ProtocolVariation.RM10WSA200408); assertTrue(seq.offeredBy(otherId)); assertFalse(seq.offeredBy(id)); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetEndpointIdentfier(){ setUpSource(); String name="abc"; EasyMock.expect(source.getName()).andReturn(name); control.replay(); SourceSequence seq=new SourceSequence(id,ProtocolVariation.RM10WSA200408); seq.setSource(source); assertEquals("Unexpected endpoint identifier",name,seq.getEndpointIdentifier()); control.verify(); }

Class: org.apache.cxf.ws.rm.persistence.PersistenceUtilsTest

InternalCallVerifier EqualityVerifier 
@Test public void testSerialiseDeserialiseAcknowledgement(){ SequenceAcknowledgement ack=new SequenceAcknowledgement(); AcknowledgementRange range=new AcknowledgementRange(); range.setLower(new Long(1)); range.setUpper(new Long(10)); ack.getAcknowledgementRange().add(range); PersistenceUtils utils=PersistenceUtils.getInstance(); InputStream is=utils.serialiseAcknowledgment(ack); SequenceAcknowledgement refAck=utils.deserialiseAcknowledgment(is); assertEquals(refAck.getAcknowledgementRange().size(),refAck.getAcknowledgementRange().size()); AcknowledgementRange refRange=refAck.getAcknowledgementRange().get(0); assertEquals(range.getLower(),refRange.getLower()); assertEquals(range.getUpper(),refRange.getUpper()); }

Class: org.apache.cxf.ws.rm.persistence.RMMessageTest

InternalCallVerifier EqualityVerifier 
@Test public void testContentInputStream() throws Exception { RMMessage msg=new RMMessage(); msg.setContent(new ByteArrayInputStream(DATA)); byte[] msgbytes=IOUtils.readBytesFromStream(msg.getContent()); assertArrayEquals(DATA,msgbytes); }

InternalCallVerifier EqualityVerifier 
@Test public void testContentCachedOutputStream() throws Exception { RMMessage msg=new RMMessage(); CachedOutputStream co=new CachedOutputStream(); co.write(DATA); msg.setContent(co.getInputStream()); byte[] msgbytes=IOUtils.readBytesFromStream(msg.getContent()); assertArrayEquals(DATA,msgbytes); co.close(); }

InternalCallVerifier EqualityVerifier 
@Test public void testAttributes() throws Exception { RMMessage msg=new RMMessage(); msg.setTo(TO); msg.setMessageNumber(1); assertEquals(msg.getTo(),TO); assertEquals(msg.getMessageNumber(),1); }

Class: org.apache.cxf.ws.rm.persistence.jdbc.RMTxStoreConfigurationTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testTxStoreBean(){ SpringBusFactory factory=new SpringBusFactory(); Bus bus=factory.createBus("org/apache/cxf/ws/rm/persistence/jdbc/txstore-bean.xml"); RMManager manager=bus.getExtension(RMManager.class); assertNotNull(manager); RMTxStore store=(RMTxStore)manager.getStore(); assertNotNull(store); assertNull("Connection should be null",store.getConnection()); assertEquals("org.apache.derby.jdbc.NoDriver",store.getDriverClassName()); assertEquals("scott",store.getUserName()); assertEquals("tiger",store.getPassword()); assertEquals("jdbc:derby://localhost:1527/rmdb;create=true",store.getUrl()); assertNull("schema should be unset",store.getSchemaName()); }

Class: org.apache.cxf.ws.rm.persistence.jdbc.RMTxStoreTestBase

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testCreateSequenceStoreInboundMessage() throws SQLException, IOException { Identifier sid1=null; try { DestinationSequence seq=control.createMock(DestinationSequence.class); sid1=new Identifier(); sid1.setValue("sequence1"); EndpointReferenceType epr=RMUtils.createAnonymousReference(); EasyMock.expect(seq.getIdentifier()).andReturn(sid1); EasyMock.expect(seq.getAcksTo()).andReturn(epr); EasyMock.expect(seq.getEndpointIdentifier()).andReturn(SERVER_ENDPOINT_ID); EasyMock.expect(seq.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408); control.replay(); store.createDestinationSequence(seq); Collection seqs=store.getDestinationSequences(SERVER_ENDPOINT_ID); assertEquals(1,seqs.size()); DestinationSequence rseq=seqs.iterator().next(); assertFalse(rseq.isAcknowledged(1)); Collection in=store.getMessages(sid1,false); assertEquals(0,in.size()); control.reset(); EasyMock.expect(seq.getIdentifier()).andReturn(sid1).anyTimes(); EasyMock.expect(seq.getAcknowledgment()).andReturn(ack1); EasyMock.expect(seq.getAcksTo()).andReturn(epr); setupInboundMessage(seq,1L,null); in=store.getMessages(sid1,false); assertEquals(1,in.size()); checkRecoveredMessages(in); seqs=store.getDestinationSequences(SERVER_ENDPOINT_ID); assertEquals(1,seqs.size()); rseq=seqs.iterator().next(); assertTrue(rseq.isAcknowledged(1)); assertFalse(rseq.isAcknowledged(10)); EasyMock.expect(seq.getIdentifier()).andReturn(sid1).anyTimes(); EasyMock.expect(seq.getAcknowledgment()).andReturn(ack2); EasyMock.expect(seq.getAcksTo()).andReturn(epr); control.replay(); store.persistIncoming(seq,null); control.reset(); seqs=store.getDestinationSequences(SERVER_ENDPOINT_ID); assertEquals(1,seqs.size()); rseq=seqs.iterator().next(); assertTrue(rseq.isAcknowledged(10)); } finally { if (null != sid1) { store.removeDestinationSequence(sid1); } Collection msgNrs=new ArrayList(); msgNrs.add(ONE); store.removeMessages(sid1,msgNrs,false); } }

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testCreateDeleteDestSequences(){ DestinationSequence seq=control.createMock(DestinationSequence.class); Identifier sid1=new Identifier(); sid1.setValue("sequence1"); EndpointReferenceType epr=RMUtils.createAnonymousReference(); EasyMock.expect(seq.getIdentifier()).andReturn(sid1); EasyMock.expect(seq.getAcksTo()).andReturn(epr); EasyMock.expect(seq.getEndpointIdentifier()).andReturn(SERVER_ENDPOINT_ID); EasyMock.expect(seq.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408); control.replay(); store.createDestinationSequence(seq); control.verify(); control.reset(); EasyMock.expect(seq.getIdentifier()).andReturn(sid1); EasyMock.expect(seq.getAcksTo()).andReturn(epr); EasyMock.expect(seq.getEndpointIdentifier()).andReturn(SERVER_ENDPOINT_ID); EasyMock.expect(seq.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408); control.replay(); try { store.createDestinationSequence(seq); fail("Expected RMStoreException was not thrown."); } catch ( RMStoreException ex) { SQLException se=(SQLException)ex.getCause(); assertEquals("23505",se.getSQLState()); } control.verify(); control.reset(); Identifier sid2=new Identifier(); sid2.setValue("sequence2"); EasyMock.expect(seq.getIdentifier()).andReturn(sid2); epr=RMUtils.createReference(NON_ANON_ACKS_TO); EasyMock.expect(seq.getAcksTo()).andReturn(epr); EasyMock.expect(seq.getEndpointIdentifier()).andReturn(CLIENT_ENDPOINT_ID); EasyMock.expect(seq.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408); control.replay(); store.createDestinationSequence(seq); control.verify(); store.removeDestinationSequence(sid1); store.removeDestinationSequence(sid2); store.removeDestinationSequence(sid2); }

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testCreateDeleteSrcSequences(){ SourceSequence seq=control.createMock(SourceSequence.class); Identifier sid1=new Identifier(); sid1.setValue("sequence1"); EasyMock.expect(seq.getIdentifier()).andReturn(sid1); EasyMock.expect(seq.getExpires()).andReturn(null); EasyMock.expect(seq.getOfferingSequenceIdentifier()).andReturn(null); EasyMock.expect(seq.getEndpointIdentifier()).andReturn(CLIENT_ENDPOINT_ID); EasyMock.expect(seq.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408); control.replay(); store.createSourceSequence(seq); control.verify(); control.reset(); EasyMock.expect(seq.getIdentifier()).andReturn(sid1); EasyMock.expect(seq.getExpires()).andReturn(null); EasyMock.expect(seq.getOfferingSequenceIdentifier()).andReturn(null); EasyMock.expect(seq.getEndpointIdentifier()).andReturn(CLIENT_ENDPOINT_ID); EasyMock.expect(seq.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408); control.replay(); try { store.createSourceSequence(seq); fail("Expected RMStoreException was not thrown."); } catch ( RMStoreException ex) { SQLException se=(SQLException)ex.getCause(); assertEquals("23505",se.getSQLState()); } control.verify(); control.reset(); Identifier sid2=new Identifier(); sid2.setValue("sequence2"); EasyMock.expect(seq.getIdentifier()).andReturn(sid2); EasyMock.expect(seq.getExpires()).andReturn(new Date()); Identifier sid3=new Identifier(); sid3.setValue("offeringSequence3"); EasyMock.expect(seq.getOfferingSequenceIdentifier()).andReturn(sid3); EasyMock.expect(seq.getEndpointIdentifier()).andReturn(SERVER_ENDPOINT_ID); EasyMock.expect(seq.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408); control.replay(); store.createSourceSequence(seq); control.verify(); store.removeSourceSequence(sid1); store.removeSourceSequence(sid2); store.removeSourceSequence(sid2); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testCreateSequenceStoreOutboundMessage() throws SQLException, IOException { Identifier sid1=null; try { SourceSequence seq=control.createMock(SourceSequence.class); sid1=new Identifier(); sid1.setValue("sequence1"); EasyMock.expect(seq.getIdentifier()).andReturn(sid1); EasyMock.expect(seq.getExpires()).andReturn(null); EasyMock.expect(seq.getOfferingSequenceIdentifier()).andReturn(null); EasyMock.expect(seq.getEndpointIdentifier()).andReturn(CLIENT_ENDPOINT_ID); EasyMock.expect(seq.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408); control.replay(); store.createSourceSequence(seq); control.reset(); Collection seqs=store.getSourceSequences(CLIENT_ENDPOINT_ID); assertEquals(1,seqs.size()); SourceSequence rseq=seqs.iterator().next(); assertFalse(rseq.isLastMessage()); Collection out=store.getMessages(sid1,true); assertEquals(0,out.size()); EasyMock.expect(seq.getIdentifier()).andReturn(sid1).anyTimes(); EasyMock.expect(seq.isLastMessage()).andReturn(true); setupOutboundMessage(seq,1L,null); out=store.getMessages(sid1,true); assertEquals(1,out.size()); checkRecoveredMessages(out); seqs=store.getSourceSequences(CLIENT_ENDPOINT_ID); assertEquals(1,seqs.size()); rseq=seqs.iterator().next(); assertTrue(rseq.isLastMessage()); EasyMock.expect(seq.getIdentifier()).andReturn(sid1).anyTimes(); EasyMock.expect(seq.getCurrentMessageNr()).andReturn(2L); EasyMock.expect(seq.isLastMessage()).andReturn(true); control.replay(); store.persistOutgoing(seq,null); control.reset(); seqs=store.getSourceSequences(CLIENT_ENDPOINT_ID); assertEquals(1,seqs.size()); rseq=seqs.iterator().next(); assertEquals(2,rseq.getCurrentMessageNr()); } finally { if (null != sid1) { store.removeSourceSequence(sid1); } Collection msgNrs=new ArrayList(); msgNrs.add(ONE); store.removeMessages(sid1,msgNrs,true); } }

EqualityVerifier 
@Test public void testCreateDeleteMessages() throws IOException, SQLException { RMMessage msg1=control.createMock(RMMessage.class); RMMessage msg2=control.createMock(RMMessage.class); Identifier sid1=new Identifier(); sid1.setValue("sequence1"); EasyMock.expect(msg1.getMessageNumber()).andReturn(ONE).anyTimes(); EasyMock.expect(msg2.getMessageNumber()).andReturn(ONE).anyTimes(); byte[] bytes=new byte[89]; EasyMock.expect(msg1.getContent()).andReturn(new ByteArrayInputStream(bytes)).anyTimes(); EasyMock.expect(msg2.getContent()).andReturn(new ByteArrayInputStream(bytes)).anyTimes(); EasyMock.expect(msg1.getAttachments()).andReturn(new ArrayList()).anyTimes(); EasyMock.expect(msg2.getAttachments()).andReturn(new ArrayList()).anyTimes(); control.replay(); Connection con=getConnection(); try { store.beginTransaction(); store.storeMessage(con,sid1,msg1,true); store.storeMessage(con,sid1,msg2,false); store.commit(con); } finally { releaseConnection(con); } control.verify(); control.reset(); EasyMock.expect(msg1.getMessageNumber()).andReturn(ONE); EasyMock.expect(msg1.getContent()).andReturn(new ByteArrayInputStream(bytes)); control.replay(); con=getConnection(); try { store.beginTransaction(); store.storeMessage(con,sid1,msg1,true); } catch ( SQLException ex) { assertEquals("23505",ex.getSQLState()); store.abort(con); } finally { releaseConnection(con); } control.verify(); control.reset(); EasyMock.expect(msg1.getMessageNumber()).andReturn(TEN).anyTimes(); EasyMock.expect(msg2.getMessageNumber()).andReturn(TEN).anyTimes(); EasyMock.expect(msg1.getContent()).andReturn(new ByteArrayInputStream(bytes)).anyTimes(); EasyMock.expect(msg2.getContent()).andReturn(new ByteArrayInputStream(bytes)).anyTimes(); EasyMock.expect(msg1.getAttachments()).andReturn(new ArrayList()).anyTimes(); EasyMock.expect(msg2.getAttachments()).andReturn(new ArrayList()).anyTimes(); control.replay(); con=getConnection(); try { store.beginTransaction(); store.storeMessage(con,sid1,msg1,true); store.storeMessage(con,sid1,msg2,false); store.commit(con); } finally { releaseConnection(con); } control.verify(); Collection messageNrs=new ArrayList(); messageNrs.add(ZERO); messageNrs.add(TEN); messageNrs.add(ONE); messageNrs.add(TEN); store.removeMessages(sid1,messageNrs,true); store.removeMessages(sid1,messageNrs,false); Identifier sid2=new Identifier(); sid1.setValue("sequence2"); store.removeMessages(sid2,messageNrs,true); }

InternalCallVerifier EqualityVerifier 
@Test public void testGetSourceSequences() throws SQLException { Identifier sid1=null; Identifier sid2=null; Collection seqs=store.getSourceSequences("unknown"); assertEquals(0,seqs.size()); try { sid1=setupSourceSequence("sequence1"); seqs=store.getSourceSequences(CLIENT_ENDPOINT_ID); assertEquals(1,seqs.size()); checkRecoveredSourceSequences(seqs); sid2=setupSourceSequence("sequence2"); seqs=store.getSourceSequences(CLIENT_ENDPOINT_ID); assertEquals(2,seqs.size()); checkRecoveredSourceSequences(seqs); } finally { if (null != sid1) { store.removeSourceSequence(sid1); } if (null != sid2) { store.removeSourceSequence(sid2); } } }

InternalCallVerifier EqualityVerifier 
@Test public void testGetMessages() throws SQLException, IOException { Identifier sid1=new Identifier(); sid1.setValue("sequence1"); Identifier sid2=new Identifier(); sid2.setValue("sequence2"); Collection out=store.getMessages(sid1,true); assertEquals(0,out.size()); Collection in=store.getMessages(sid1,false); assertEquals(0,out.size()); try { setupMessage(sid1,ONE,null,true); setupMessage(sid1,ONE,null,false); out=store.getMessages(sid1,true); assertEquals(1,out.size()); checkRecoveredMessages(out); in=store.getMessages(sid1,false); assertEquals(1,in.size()); checkRecoveredMessages(in); setupMessage(sid1,TEN,NON_ANON_ACKS_TO,true); setupMessage(sid1,TEN,NON_ANON_ACKS_TO,false); out=store.getMessages(sid1,true); assertEquals(2,out.size()); checkRecoveredMessages(out); in=store.getMessages(sid1,false); assertEquals(2,in.size()); checkRecoveredMessages(in); } finally { Collection msgNrs=new ArrayList(); msgNrs.add(ONE); msgNrs.add(TEN); store.removeMessages(sid1,msgNrs,true); store.removeMessages(sid1,msgNrs,false); } }

InternalCallVerifier EqualityVerifier 
@Test public void testGetDestinationSequences() throws SQLException, IOException { Identifier sid1=null; Identifier sid2=null; Collection seqs=store.getDestinationSequences("unknown"); assertEquals(0,seqs.size()); try { sid1=setupDestinationSequence("sequence1"); seqs=store.getDestinationSequences(SERVER_ENDPOINT_ID); assertEquals(1,seqs.size()); checkRecoveredDestinationSequences(seqs); sid2=setupDestinationSequence("sequence2"); seqs=store.getDestinationSequences(SERVER_ENDPOINT_ID); assertEquals(2,seqs.size()); checkRecoveredDestinationSequences(seqs); } finally { if (null != sid1) { store.removeDestinationSequence(sid1); } if (null != sid2) { store.removeDestinationSequence(sid2); } } }

Class: org.apache.cxf.ws.rm.policy.PolicyUtilsTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testIntersect(){ RMAssertion rma=new RMAssertion(); RMConfiguration cfg0=new RMConfiguration(); assertTrue(RMPolicyUtilities.equals(cfg0,RMPolicyUtilities.intersect(rma,cfg0))); InactivityTimeout aiat=new RMAssertion.InactivityTimeout(); aiat.setMilliseconds(new Long(7200000)); rma.setInactivityTimeout(aiat); cfg0.setInactivityTimeout(new Long(3600000)); RMConfiguration cfg1=RMPolicyUtilities.intersect(rma,cfg0); assertEquals(7200000L,cfg1.getInactivityTimeout().longValue()); assertNull(cfg1.getBaseRetransmissionInterval()); assertNull(cfg1.getAcknowledgementInterval()); assertFalse(cfg1.isExponentialBackoff()); BaseRetransmissionInterval abri=new RMAssertion.BaseRetransmissionInterval(); abri.setMilliseconds(new Long(20000)); rma.setBaseRetransmissionInterval(abri); cfg0.setBaseRetransmissionInterval(new Long(10000)); cfg1=RMPolicyUtilities.intersect(rma,cfg0); assertEquals(7200000L,cfg1.getInactivityTimeout().longValue()); assertEquals(20000L,cfg1.getBaseRetransmissionInterval().longValue()); assertNull(cfg1.getAcknowledgementInterval()); assertFalse(cfg1.isExponentialBackoff()); AcknowledgementInterval aai=new RMAssertion.AcknowledgementInterval(); aai.setMilliseconds(new Long(2000)); rma.setAcknowledgementInterval(aai); cfg1=RMPolicyUtilities.intersect(rma,cfg0); assertEquals(7200000L,cfg1.getInactivityTimeout().longValue()); assertEquals(20000L,cfg1.getBaseRetransmissionInterval().longValue()); assertEquals(2000L,cfg1.getAcknowledgementInterval().longValue()); assertFalse(cfg1.isExponentialBackoff()); cfg0.setExponentialBackoff(true); cfg1=RMPolicyUtilities.intersect(rma,cfg0); assertEquals(7200000L,cfg1.getInactivityTimeout().longValue()); assertEquals(20000L,cfg1.getBaseRetransmissionInterval().longValue()); assertEquals(2000L,cfg1.getAcknowledgementInterval().longValue()); assertTrue(cfg1.isExponentialBackoff()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier IdentityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGetRMConfiguration(){ RMConfiguration cfg=new RMConfiguration(); cfg.setBaseRetransmissionInterval(new Long(3000)); cfg.setExponentialBackoff(true); Message message=control.createMock(Message.class); EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(null); control.replay(); assertSame(cfg,RMPolicyUtilities.getRMConfiguration(cfg,message)); control.verify(); control.reset(); AssertionInfoMap aim=control.createMock(AssertionInfoMap.class); EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(aim); Collection ais=new ArrayList(); EasyMock.expect(aim.get(RM10Constants.RMASSERTION_QNAME)).andReturn(ais); control.replay(); assertSame(cfg,RMPolicyUtilities.getRMConfiguration(cfg,message)); control.verify(); control.reset(); RMAssertion b=new RMAssertion(); BaseRetransmissionInterval bbri=new RMAssertion.BaseRetransmissionInterval(); bbri.setMilliseconds(new Long(2000)); b.setBaseRetransmissionInterval(bbri); JaxbAssertion assertion=new JaxbAssertion(); assertion.setName(RM10Constants.RMASSERTION_QNAME); assertion.setData(b); AssertionInfo ai=new AssertionInfo(assertion); ais.add(ai); EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(aim); EasyMock.expect(aim.get(RM10Constants.RMASSERTION_QNAME)).andReturn(ais); control.replay(); RMConfiguration cfg1=RMPolicyUtilities.getRMConfiguration(cfg,message); assertNull(cfg1.getAcknowledgementInterval()); assertNull(cfg1.getInactivityTimeout()); assertEquals(2000L,cfg1.getBaseRetransmissionInterval().longValue()); assertTrue(cfg1.isExponentialBackoff()); control.verify(); }

Class: org.apache.cxf.ws.rm.soap.RMSoapInInterceptorTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDecodeAcknowledgements2() throws XMLStreamException { SoapMessage message=setUpInboundMessage("resources/Acknowledgment2.xml"); RMSoapInInterceptor codec=new RMSoapInInterceptor(); codec.handleMessage(message); RMProperties rmps=RMContextUtils.retrieveRMProperties(message,false); Collection acks=rmps.getAcks(); assertNotNull(acks); assertEquals(1,acks.size()); SequenceAcknowledgement ack=acks.iterator().next(); assertNotNull(ack); assertEquals(1,ack.getAcknowledgementRange().size()); AcknowledgementRange r1=ack.getAcknowledgementRange().get(0); verifyRange(r1,1,3); assertNull(rmps.getSequence()); assertNull(rmps.getAcksRequested()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDecodeAcknowledgements() throws XMLStreamException { SoapMessage message=setUpInboundMessage("resources/Acknowledgment.xml"); RMSoapInInterceptor codec=new RMSoapInInterceptor(); codec.handleMessage(message); RMProperties rmps=RMContextUtils.retrieveRMProperties(message,false); Collection acks=rmps.getAcks(); assertNotNull(acks); assertEquals(1,acks.size()); SequenceAcknowledgement ack=acks.iterator().next(); assertNotNull(ack); assertEquals(ack.getIdentifier().getValue(),SEQ_IDENTIFIER); assertEquals(2,ack.getAcknowledgementRange().size()); AcknowledgementRange r1=ack.getAcknowledgementRange().get(0); AcknowledgementRange r2=ack.getAcknowledgementRange().get(1); verifyRange(r1,1,1); verifyRange(r2,3,3); assertNull(rmps.getSequence()); assertNull(rmps.getAcksRequested()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDecodeAcksRequested() throws XMLStreamException { SoapMessage message=setUpInboundMessage("resources/Retransmission.xml"); RMSoapInInterceptor codec=new RMSoapInInterceptor(); codec.handleMessage(message); RMProperties rmps=RMContextUtils.retrieveRMProperties(message,false); Collection requested=rmps.getAcksRequested(); assertNotNull(requested); assertEquals(1,requested.size()); AckRequestedType ar=requested.iterator().next(); assertNotNull(ar); assertEquals(ar.getIdentifier().getValue(),SEQ_IDENTIFIER); SequenceType s=rmps.getSequence(); assertNotNull(s); assertEquals(s.getIdentifier().getValue(),SEQ_IDENTIFIER); assertEquals(s.getMessageNumber(),MSG2_MESSAGE_NUMBER); assertNull(rmps.getAcks()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDecodeSequence() throws XMLStreamException { SoapMessage message=setUpInboundMessage("resources/Message1.xml"); RMSoapInInterceptor codec=new RMSoapInInterceptor(); codec.handleMessage(message); RMProperties rmps=RMContextUtils.retrieveRMProperties(message,false); SequenceType st=rmps.getSequence(); assertNotNull(st); assertEquals(st.getIdentifier().getValue(),SEQ_IDENTIFIER); assertEquals(st.getMessageNumber(),MSG1_MESSAGE_NUMBER); assertNull(rmps.getAcks()); assertNull(rmps.getAcksRequested()); }

Class: org.apache.cxf.ws.rm.soap.RetransmissionQueueImplTest

APIUtilityVerifier InternalCallVerifier IdentityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCacheUnacknowledged(){ SoapMessage message1=setUpMessage("sequence1",ONE); SoapMessage message2=setUpMessage("sequence2",ONE); SoapMessage message3=setUpMessage("sequence1",TWO); setupMessagePolicies(message1); setupMessagePolicies(message2); setupMessagePolicies(message3); endpoint.handleAccept("sequence1",1,message1); EasyMock.expectLastCall(); endpoint.handleAccept("sequence2",1,message2); EasyMock.expectLastCall(); endpoint.handleAccept("sequence1",2,message3); EasyMock.expectLastCall(); ready(false); assertNotNull("expected resend candidate",queue.cacheUnacknowledged(message1)); assertEquals("expected non-empty unacked map",1,queue.getUnacknowledged().size()); List sequence1List=queue.getUnacknowledged().get("sequence1"); assertNotNull("expected non-null context list",sequence1List); assertSame("expected context list entry",message1,sequence1List.get(0).getMessage()); assertNotNull("expected resend candidate",queue.cacheUnacknowledged(message2)); assertEquals("unexpected unacked map size",2,queue.getUnacknowledged().size()); List sequence2List=queue.getUnacknowledged().get("sequence2"); assertNotNull("expected non-null context list",sequence2List); assertSame("expected context list entry",message2,sequence2List.get(0).getMessage()); assertNotNull("expected resend candidate",queue.cacheUnacknowledged(message3)); assertEquals("un expected unacked map size",2,queue.getUnacknowledged().size()); sequence1List=queue.getUnacknowledged().get("sequence1"); assertNotNull("expected non-null context list",sequence1List); assertSame("expected context list entry",message3,sequence1List.get(1).getMessage()); }

InternalCallVerifier EqualityVerifier 
@Test public void testPurgeAcknowledgedNone(){ Long[] messageNumbers={TEN,ONE}; SourceSequence sequence=setUpSequence("sequence1",messageNumbers,new boolean[]{false,false}); List sequenceList=new ArrayList(); queue.getUnacknowledged().put("sequence1",sequenceList); SoapMessage message1=setUpMessage("sequence1",messageNumbers[0]); setupMessagePolicies(message1); SoapMessage message2=setUpMessage("sequence1",messageNumbers[1]); setupMessagePolicies(message2); ready(false); sequenceList.add(queue.createResendCandidate(message1)); sequenceList.add(queue.createResendCandidate(message2)); queue.purgeAcknowledged(sequence); assertEquals("unexpected unacked map size",1,queue.getUnacknowledged().size()); assertEquals("unexpected unacked list size",2,sequenceList.size()); }

BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testResendCandidateAttempted(){ SoapMessage message=createMock(SoapMessage.class); setupMessagePolicies(message); ready(true); long now=System.currentTimeMillis(); RetransmissionQueueImpl.ResendCandidate candidate=queue.createResendCandidate(message); candidate.attempted(); assertEquals(1,candidate.getRetries()); Date refDate=new Date(now + 15000); assertTrue(!candidate.getNext().before(refDate)); refDate=new Date(now + 17000); assertTrue(!candidate.getNext().after(refDate)); assertTrue(!candidate.isPending()); }

BooleanVerifier IdentityVerifier EqualityVerifier HybridVerifier 
@Test public void testResendCandidateCtor(){ SoapMessage message=createMock(SoapMessage.class); setupMessagePolicies(message); control.replay(); long now=System.currentTimeMillis(); RetransmissionQueueImpl.ResendCandidate candidate=queue.createResendCandidate(message); assertSame(message,candidate.getMessage()); assertEquals(0,candidate.getRetries()); Date refDate=new Date(now + 5000); assertTrue(!candidate.getNext().before(refDate)); refDate=new Date(now + 7000); assertTrue(!candidate.getNext().after(refDate)); assertTrue(!candidate.isPending()); }

InternalCallVerifier IdentityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCtor(){ ready(false); assertNotNull("expected unacked map",queue.getUnacknowledged()); assertEquals("expected empty unacked map",0,queue.getUnacknowledged().size()); queue=new RetransmissionQueueImpl(null); assertNull(queue.getManager()); queue.setManager(manager); assertSame("Unexpected RMManager",manager,queue.getManager()); }

IterativeVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testResendCandidateMaxRetries(){ SoapMessage message=createMock(SoapMessage.class); setupMessagePolicies(message); setupRetryPolicy(message); ready(true); RetransmissionQueueImpl.ResendCandidate candidate=queue.createResendCandidate(message); assertEquals(3,candidate.getMaxRetries()); Date next=null; for (int i=1; i < 3; i++) { next=candidate.getNext(); candidate.attempted(); assertEquals(i,candidate.getRetries()); assertTrue(candidate.getNext().after(next)); } next=candidate.getNext(); candidate.attempted(); assertEquals(3,candidate.getRetries()); assertFalse(candidate.getNext().after(next)); }

InternalCallVerifier EqualityVerifier 
@Test public void testPurgeAcknowledgedSome(){ Long[] messageNumbers={TEN,ONE}; SourceSequence sequence=setUpSequence("sequence1",messageNumbers,new boolean[]{true,false}); List sequenceList=new ArrayList(); queue.getUnacknowledged().put("sequence1",sequenceList); SoapMessage message1=setUpMessage("sequence1",messageNumbers[0]); setupMessagePolicies(message1); SoapMessage message2=setUpMessage("sequence1",messageNumbers[1]); setupMessagePolicies(message2); endpoint.handleAcknowledgment("sequence1",TEN,message1); EasyMock.expectLastCall(); ready(false); sequenceList.add(queue.createResendCandidate(message1)); sequenceList.add(queue.createResendCandidate(message2)); queue.purgeAcknowledged(sequence); assertEquals("unexpected unacked map size",1,queue.getUnacknowledged().size()); assertEquals("unexpected unacked list size",1,sequenceList.size()); }

APIUtilityVerifier EqualityVerifier 
@Test public void testCountUnacknowledgedUnknownSequence(){ Long[] messageNumbers={TEN,ONE}; SourceSequence sequence=setUpSequence("sequence1",messageNumbers,null); ready(false); assertEquals("unexpected unacked count",0,queue.countUnacknowledged(sequence)); }

InternalCallVerifier EqualityVerifier 
@Test public void testPurgeAcknowledgedAll(){ Long[] messageNumbers={TEN,ONE}; SourceSequence sequence=setUpSequence("sequence1",messageNumbers,new boolean[]{true,true}); List sequenceList=new ArrayList(); queue.getUnacknowledged().put("sequence1",sequenceList); SoapMessage message1=setUpMessage("sequence1",messageNumbers[0]); setupMessagePolicies(message1); SoapMessage message2=setUpMessage("sequence1",messageNumbers[1]); setupMessagePolicies(message2); endpoint.handleAcknowledgment("sequence1",TEN,message1); EasyMock.expectLastCall(); endpoint.handleAcknowledgment("sequence1",ONE,message2); EasyMock.expectLastCall(); ready(false); sequenceList.add(queue.createResendCandidate(message1)); sequenceList.add(queue.createResendCandidate(message2)); queue.purgeAcknowledged(sequence); assertEquals("unexpected unacked map size",0,queue.getUnacknowledged().size()); assertEquals("unexpected unacked list size",0,sequenceList.size()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testCountUnacknowledged(){ Long[] messageNumbers={TEN,ONE}; SourceSequence sequence=setUpSequence("sequence1",messageNumbers,null); List sequenceList=new ArrayList(); queue.getUnacknowledged().put("sequence1",sequenceList); SoapMessage message1=setUpMessage("sequence1",messageNumbers[0],false); setupMessagePolicies(message1); SoapMessage message2=setUpMessage("sequence1",messageNumbers[1],false); setupMessagePolicies(message2); ready(false); sequenceList.add(queue.createResendCandidate(message1)); sequenceList.add(queue.createResendCandidate(message2)); assertEquals("unexpected unacked count",2,queue.countUnacknowledged(sequence)); assertTrue("queue is empty",!queue.isEmpty()); }

Class: org.apache.cxf.ws.rm.soap.SoapFaultFactoryTest

InternalCallVerifier EqualityVerifier 
@Test public void testToString(){ SoapBinding sb=control.createMock(SoapBinding.class); EasyMock.expect(sb.getSoapVersion()).andReturn(Soap11.getInstance()); SoapFault fault=control.createMock(SoapFault.class); EasyMock.expect(fault.getReason()).andReturn("r"); EasyMock.expect(fault.getFaultCode()).andReturn(new QName("ns","code")); EasyMock.expect(fault.getSubCode()).andReturn(new QName("ns","subcode")); control.replay(); SoapFaultFactory factory=new SoapFaultFactory(sb); assertEquals("Reason: r, code: {ns}code, subCode: {ns}subcode",factory.toString(fault)); control.verify(); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void createSoap12Fault(){ SoapBinding sb=control.createMock(SoapBinding.class); EasyMock.expect(sb.getSoapVersion()).andReturn(Soap12.getInstance()); Identifier id=new Identifier(); id.setValue("sid"); setupSequenceFault(true,RM10Constants.UNKNOWN_SEQUENCE_FAULT_QNAME,id); control.replay(); SoapFaultFactory factory=new SoapFaultFactory(sb); SoapFault fault=(SoapFault)factory.createFault(sf,createInboundMessage()); assertEquals("reason",fault.getReason()); assertEquals(Soap12.getInstance().getSender(),fault.getFaultCode()); assertEquals(RM10Constants.UNKNOWN_SEQUENCE_FAULT_QNAME,fault.getSubCode()); Element elem=fault.getDetail(); assertEquals(RM10Constants.NAMESPACE_URI,elem.getNamespaceURI()); assertEquals("Identifier",elem.getLocalName()); assertNull(fault.getCause()); control.verify(); }

InternalCallVerifier IdentityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void createSoap11Fault(){ SoapBinding sb=control.createMock(SoapBinding.class); EasyMock.expect(sb.getSoapVersion()).andReturn(Soap11.getInstance()); setupSequenceFault(false,RM10Constants.SEQUENCE_TERMINATED_FAULT_QNAME,null); control.replay(); SoapFaultFactory factory=new SoapFaultFactory(sb); SoapFault fault=(SoapFault)factory.createFault(sf,createInboundMessage()); assertEquals("reason",fault.getReason()); assertEquals(Soap11.getInstance().getReceiver(),fault.getFaultCode()); assertNull(fault.getSubCode()); assertNull(fault.getDetail()); assertSame(sf,fault.getCause()); control.verify(); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void createSoap12FaultWithAcknowledgementDetail(){ SoapBinding sb=control.createMock(SoapBinding.class); EasyMock.expect(sb.getSoapVersion()).andReturn(Soap12.getInstance()); SequenceAcknowledgement ack=new SequenceAcknowledgement(); Identifier id=new Identifier(); id.setValue("sid"); ack.setIdentifier(id); SequenceAcknowledgement.AcknowledgementRange range=new SequenceAcknowledgement.AcknowledgementRange(); range.setLower(new Long(1)); range.setUpper(new Long(10)); ack.getAcknowledgementRange().add(range); setupSequenceFault(true,RM10Constants.INVALID_ACKNOWLEDGMENT_FAULT_QNAME,ack); control.replay(); SoapFaultFactory factory=new SoapFaultFactory(sb); SoapFault fault=(SoapFault)factory.createFault(sf,createInboundMessage()); assertEquals("reason",fault.getReason()); assertEquals(Soap12.getInstance().getSender(),fault.getFaultCode()); assertEquals(RM10Constants.INVALID_ACKNOWLEDGMENT_FAULT_QNAME,fault.getSubCode()); Element elem=fault.getDetail(); assertEquals(RM10Constants.NAMESPACE_URI,elem.getNamespaceURI()); assertEquals("SequenceAcknowledgement",elem.getLocalName()); control.verify(); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void createSoap12FaultWithoutDetail(){ SoapBinding sb=control.createMock(SoapBinding.class); EasyMock.expect(sb.getSoapVersion()).andReturn(Soap12.getInstance()); setupSequenceFault(true,RM10Constants.CREATE_SEQUENCE_REFUSED_FAULT_QNAME,null); control.replay(); SoapFaultFactory factory=new SoapFaultFactory(sb); SoapFault fault=(SoapFault)factory.createFault(sf,createInboundMessage()); assertEquals("reason",fault.getReason()); assertEquals(Soap12.getInstance().getSender(),fault.getFaultCode()); assertEquals(RM10Constants.CREATE_SEQUENCE_REFUSED_FAULT_QNAME,fault.getSubCode()); assertNull(fault.getDetail()); control.verify(); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void createSoap12FaultWithIdentifierDetail(){ SoapBinding sb=control.createMock(SoapBinding.class); EasyMock.expect(sb.getSoapVersion()).andReturn(Soap12.getInstance()); Identifier id=new Identifier(); id.setValue("sid"); setupSequenceFault(true,RM10Constants.UNKNOWN_SEQUENCE_FAULT_QNAME,id); control.replay(); SoapFaultFactory factory=new SoapFaultFactory(sb); SoapFault fault=(SoapFault)factory.createFault(sf,createInboundMessage()); assertEquals("reason",fault.getReason()); assertEquals(Soap12.getInstance().getSender(),fault.getFaultCode()); assertEquals(RM10Constants.UNKNOWN_SEQUENCE_FAULT_QNAME,fault.getSubCode()); Element elem=fault.getDetail(); assertEquals(RM10Constants.NAMESPACE_URI,elem.getNamespaceURI()); assertEquals("Identifier",elem.getLocalName()); control.verify(); }

Class: org.apache.cxf.ws.security.cache.EHCacheUtilsTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testUseGlobalManager(){ Bus bus=BusFactory.getThreadDefaultBus(); Configuration conf=ConfigurationFactory.parseConfiguration(EHCacheManagerHolder.class.getResource("/cxf-test-ehcache.xml")); conf.setName("myGlobalConfig"); CacheManager.newInstance(conf); CacheManager manager=EHCacheUtils.getCacheManager(bus,EHCacheManagerHolder.class.getResource("/cxf-test-ehcache.xml")); assertFalse(manager.getName().equals("myGlobalConfig")); EHCacheManagerHolder.releaseCacheManger(manager); assertEquals(Status.STATUS_SHUTDOWN,manager.getStatus()); bus.setProperty(EHCacheUtils.GLOBAL_EHCACHE_MANAGER_NAME,"myGlobalConfig"); manager=EHCacheUtils.getCacheManager(bus,EHCacheManagerHolder.class.getResource("/cxf-test-ehcache.xml")); assertEquals("myGlobalConfig",manager.getName()); EHCacheManagerHolder.releaseCacheManger(manager); assertEquals(Status.STATUS_ALIVE,manager.getStatus()); manager.shutdown(); assertEquals(Status.STATUS_SHUTDOWN,manager.getStatus()); bus.setProperty(EHCacheUtils.GLOBAL_EHCACHE_MANAGER_NAME,"myGlobalConfigXXX"); manager=EHCacheUtils.getCacheManager(bus,EHCacheManagerHolder.class.getResource("/cxf-test-ehcache.xml")); assertFalse(manager.getName().equals("myGlobalConfig")); EHCacheManagerHolder.releaseCacheManger(manager); assertEquals(Status.STATUS_SHUTDOWN,manager.getStatus()); }

Class: org.apache.cxf.ws.security.sts.STSClientTest

InternalCallVerifier EqualityVerifier 
@Test public void testConfigureViaEPR() throws Exception { final Set> addressingClasses=new HashSet>(); addressingClasses.add(org.apache.cxf.ws.addressing.wsdl.ObjectFactory.class); addressingClasses.add(org.apache.cxf.ws.addressing.ObjectFactory.class); JAXBContext ctx=JAXBContextCache.getCachedContextAndSchemas(addressingClasses,null,null,null,true).getContext(); Unmarshaller um=ctx.createUnmarshaller(); InputStream inStream=getClass().getResourceAsStream("epr.xml"); JAXBElement el=(JAXBElement)um.unmarshal(inStream); EndpointReferenceType ref=(EndpointReferenceType)el.getValue(); Bus bus=BusFactory.getThreadDefaultBus(); STSClient client=new STSClient(bus); client.configureViaEPR(ref,false); assertEquals("http://localhost:8080/jaxws-samples-wsse-policy-trust-sts/SecurityTokenService?wsdl",client.getWsdlLocation()); assertEquals(new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512/","SecurityTokenService"),client.getServiceQName()); assertEquals(new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512/","UT_Port"),client.getEndpointQName()); }

Class: org.apache.cxf.ws.security.wss4j.CustomPolicyAlgorithmsTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSHA256AsymSigAlgorithm() throws Exception { final String rsaSha2SigMethod="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"; String policyName="signed_elements_policy.xml"; Policy policy=policyBuilder.getPolicy(this.getResourceAsStream(policyName)); AssertionInfoMap aim=new AssertionInfoMap(policy); AssertionInfo assertInfo=aim.get(SP12Constants.ASYMMETRIC_BINDING).iterator().next(); AsymmetricBinding binding=(AsymmetricBinding)assertInfo.getAssertion(); binding.getAlgorithmSuite().setAsymmetricSignature(rsaSha2SigMethod); String sigMethod=binding.getAlgorithmSuite().getAsymmetricSignature(); assertNotNull(sigMethod); assertEquals(rsaSha2SigMethod,sigMethod); }

Class: org.apache.cxf.ws.security.wss4j.DOMToStaxEncryptionIdentifierTest

EqualityVerifier 
@Test public void testEncryptIssuerSerial() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setDecryptionCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map properties=new HashMap(); properties.put(WSHandlerConstants.ACTION,WSHandlerConstants.ENCRYPT); properties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); properties.put(WSHandlerConstants.ENC_PROP_FILE,"outsecurity.properties"); properties.put(WSHandlerConstants.USER,"myalias"); properties.put(WSHandlerConstants.ENC_KEY_ID,"IssuerSerial"); WSS4JOutInterceptor ohandler=new WSS4JOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testEncryptDirectReference() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setDecryptionCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map properties=new HashMap(); properties.put(WSHandlerConstants.ACTION,WSHandlerConstants.ENCRYPT); properties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); properties.put(WSHandlerConstants.ENC_PROP_FILE,"outsecurity.properties"); properties.put(WSHandlerConstants.USER,"myalias"); properties.put(WSHandlerConstants.ENC_KEY_ID,"DirectReference"); WSS4JOutInterceptor ohandler=new WSS4JOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testEncryptThumbprint() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setDecryptionCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map properties=new HashMap(); properties.put(WSHandlerConstants.ACTION,WSHandlerConstants.ENCRYPT); properties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); properties.put(WSHandlerConstants.ENC_PROP_FILE,"outsecurity.properties"); properties.put(WSHandlerConstants.USER,"myalias"); properties.put(WSHandlerConstants.ENC_KEY_ID,"Thumbprint"); WSS4JOutInterceptor ohandler=new WSS4JOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testEncryptEncryptedKeySHA1() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setDecryptionCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map properties=new HashMap(); properties.put(WSHandlerConstants.ACTION,WSHandlerConstants.ENCRYPT); properties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); properties.put(WSHandlerConstants.ENC_PROP_FILE,"outsecurity.properties"); properties.put(WSHandlerConstants.USER,"myalias"); properties.put(WSHandlerConstants.ENC_KEY_ID,"EncryptedKeySHA1"); WSS4JOutInterceptor ohandler=new WSS4JOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testEncryptX509() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setDecryptionCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map properties=new HashMap(); properties.put(WSHandlerConstants.ACTION,WSHandlerConstants.ENCRYPT); properties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); properties.put(WSHandlerConstants.ENC_PROP_FILE,"outsecurity.properties"); properties.put(WSHandlerConstants.USER,"myalias"); properties.put(WSHandlerConstants.ENC_KEY_ID,"X509KeyIdentifier"); WSS4JOutInterceptor ohandler=new WSS4JOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

Class: org.apache.cxf.ws.security.wss4j.DOMToStaxRoundTripTest

EqualityVerifier 
@Test public void testSignature() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setSignatureVerificationCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map properties=new HashMap(); properties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE); properties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); properties.put(WSHandlerConstants.SIG_PROP_FILE,"outsecurity.properties"); properties.put(WSHandlerConstants.USER,"myalias"); WSS4JOutInterceptor ohandler=new WSS4JOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

UtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testUsernameTokenText() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setUsernameTokenPasswordType(WSSConstants.UsernameTokenPasswordType.PASSWORD_TEXT); inProperties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map properties=new HashMap(); properties.put(WSHandlerConstants.ACTION,WSHandlerConstants.USERNAME_TOKEN); properties.put(WSHandlerConstants.PASSWORD_TYPE,WSConstants.PW_TEXT); properties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); properties.put(WSHandlerConstants.USER,"username"); WSS4JOutInterceptor ohandler=new WSS4JOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); service.getInInterceptors().remove(inhandler); inProperties.setUsernameTokenPasswordType(WSSConstants.UsernameTokenPasswordType.PASSWORD_DIGEST); inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); service.put(SecurityConstants.RETURN_SECURITY_ERROR,true); try { echo.echo("test"); fail("Failure expected on the wrong password type"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { String error="The security token could not be authenticated or authorized"; assertTrue(ex.getMessage().contains(error)); } }

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testEncryptionAlgorithms() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setDecryptionCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map properties=new HashMap(); properties.put(WSHandlerConstants.ACTION,WSHandlerConstants.ENCRYPT); properties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); properties.put(WSHandlerConstants.ENC_PROP_FILE,"outsecurity.properties"); properties.put(WSHandlerConstants.USER,"myalias"); properties.put(WSHandlerConstants.ENC_KEY_TRANSPORT,WSConstants.KEYTRANSPORT_RSA15); properties.put(WSHandlerConstants.ENC_SYM_ALGO,WSConstants.TRIPLE_DES); WSS4JOutInterceptor ohandler=new WSS4JOutInterceptor(properties); client.getOutInterceptors().add(ohandler); try { echo.echo("test"); fail("Failure expected as RSA v1.5 is not allowed by default"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { } inProperties.setAllowRSA15KeyTransportAlgorithm(true); service.getInInterceptors().remove(inhandler); inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testEncryptUsernameToken() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setDecryptionCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map properties=new HashMap(); properties.put(WSHandlerConstants.ACTION,WSHandlerConstants.USERNAME_TOKEN + " " + WSHandlerConstants.ENCRYPT); properties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); properties.put(WSHandlerConstants.ENC_PROP_FILE,"outsecurity.properties"); properties.put(WSHandlerConstants.USER,"username"); properties.put(WSHandlerConstants.ENCRYPTION_USER,"myalias"); WSS4JOutInterceptor ohandler=new WSS4JOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testTimestamp() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map properties=new HashMap(); properties.put(WSHandlerConstants.ACTION,WSHandlerConstants.TIMESTAMP); WSS4JOutInterceptor ohandler=new WSS4JOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

UtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testUsernameTokenDigest() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setUsernameTokenPasswordType(WSSConstants.UsernameTokenPasswordType.PASSWORD_DIGEST); inProperties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map properties=new HashMap(); properties.put(WSHandlerConstants.ACTION,WSHandlerConstants.USERNAME_TOKEN); properties.put(WSHandlerConstants.PASSWORD_TYPE,WSConstants.PW_DIGEST); properties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); properties.put(WSHandlerConstants.USER,"username"); WSS4JOutInterceptor ohandler=new WSS4JOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); service.getInInterceptors().remove(inhandler); inProperties.setUsernameTokenPasswordType(WSSConstants.UsernameTokenPasswordType.PASSWORD_TEXT); inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); service.put(SecurityConstants.RETURN_SECURITY_ERROR,true); try { echo.echo("test"); fail("Failure expected on the wrong password type"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { String error="The security token could not be authenticated or authorized"; assertTrue(ex.getMessage().contains(error)); } }

EqualityVerifier 
@Test public void testSignatureConfirmation() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setSignatureVerificationCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); WSSSecurityProperties outProperties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.SIGNATURE); actions.add(WSSConstants.SIGNATURE_CONFIRMATION); outProperties.setActions(actions); outProperties.setSignatureUser("myalias"); Properties outCryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); outProperties.setSignatureCryptoProperties(outCryptoProperties); outProperties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor staxOhandler=new WSS4JStaxOutInterceptor(outProperties); service.getOutInterceptors().add(staxOhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map properties=new HashMap(); properties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE); properties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); properties.put(WSHandlerConstants.SIG_PROP_FILE,"outsecurity.properties"); properties.put(WSHandlerConstants.ENABLE_SIGNATURE_CONFIRMATION,"true"); properties.put(WSHandlerConstants.USER,"myalias"); WSS4JOutInterceptor ohandler=new WSS4JOutInterceptor(properties); client.getOutInterceptors().add(ohandler); Map domInProperties=new HashMap(); domInProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE); domInProperties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); domInProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE,"insecurity.properties"); domInProperties.put(WSHandlerConstants.ENABLE_SIGNATURE_CONFIRMATION,"true"); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(domInProperties); client.getInInterceptors().add(inInterceptor); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSignaturePKI() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); Properties cryptoProperties=CryptoFactory.getProperties("cxfca.properties",this.getClass().getClassLoader()); inProperties.setSignatureVerificationCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map properties=new HashMap(); properties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE); properties.put(WSHandlerConstants.PW_CALLBACK_REF,new KeystorePasswordCallback()); properties.put(WSHandlerConstants.SIG_PROP_FILE,"alice.properties"); properties.put(WSHandlerConstants.USER,"alice"); properties.put(WSHandlerConstants.USE_SINGLE_CERTIFICATE,"true"); properties.put(WSHandlerConstants.SIG_KEY_ID,"DirectReference"); WSS4JOutInterceptor ohandler=new WSS4JOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSignatureTimestamp() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setSignatureVerificationCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map properties=new HashMap(); properties.put(WSHandlerConstants.ACTION,WSHandlerConstants.TIMESTAMP + " " + WSHandlerConstants.SIGNATURE); properties.put(WSHandlerConstants.SIGNATURE_PARTS,"{}{" + WSSConstants.NS_WSU10 + "}Timestamp;"+ "{}{"+ WSSConstants.NS_SOAP11+ "}Body;"); properties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); properties.put(WSHandlerConstants.SIG_PROP_FILE,"outsecurity.properties"); properties.put(WSHandlerConstants.USER,"myalias"); WSS4JOutInterceptor ohandler=new WSS4JOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testEncrypt() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setDecryptionCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map properties=new HashMap(); properties.put(WSHandlerConstants.ACTION,WSHandlerConstants.ENCRYPT); properties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); properties.put(WSHandlerConstants.ENC_PROP_FILE,"outsecurity.properties"); properties.put(WSHandlerConstants.USER,"myalias"); WSS4JOutInterceptor ohandler=new WSS4JOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSignedUsernameToken() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setSignatureVerificationCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map properties=new HashMap(); properties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.USERNAME_TOKEN); properties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); properties.put(WSHandlerConstants.SIG_PROP_FILE,"outsecurity.properties"); properties.put(WSHandlerConstants.USER,"myalias"); WSS4JOutInterceptor ohandler=new WSS4JOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testEncryptSignature() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setSignatureVerificationCryptoProperties(cryptoProperties); inProperties.setDecryptionCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map properties=new HashMap(); properties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.ENCRYPT); properties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); properties.put(WSHandlerConstants.SIG_PROP_FILE,"outsecurity.properties"); properties.put(WSHandlerConstants.ENC_PROP_FILE,"outsecurity.properties"); properties.put(WSHandlerConstants.USER,"myalias"); WSS4JOutInterceptor ohandler=new WSS4JOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

Class: org.apache.cxf.ws.security.wss4j.DOMToStaxSignatureIdentifierTest

EqualityVerifier 
@Test public void testSignatureX509() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setSignatureVerificationCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map properties=new HashMap(); properties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE); properties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); properties.put(WSHandlerConstants.SIG_PROP_FILE,"outsecurity.properties"); properties.put(WSHandlerConstants.USER,"myalias"); properties.put(WSHandlerConstants.SIG_KEY_ID,"X509KeyIdentifier"); WSS4JOutInterceptor ohandler=new WSS4JOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSignatureDirectReference() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setSignatureVerificationCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map properties=new HashMap(); properties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE); properties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); properties.put(WSHandlerConstants.SIG_PROP_FILE,"outsecurity.properties"); properties.put(WSHandlerConstants.USER,"myalias"); properties.put(WSHandlerConstants.SIG_KEY_ID,"DirectReference"); WSS4JOutInterceptor ohandler=new WSS4JOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSignatureIssuerSerial() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setSignatureVerificationCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map properties=new HashMap(); properties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE); properties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); properties.put(WSHandlerConstants.SIG_PROP_FILE,"outsecurity.properties"); properties.put(WSHandlerConstants.USER,"myalias"); properties.put(WSHandlerConstants.SIG_KEY_ID,"IssuerSerial"); WSS4JOutInterceptor ohandler=new WSS4JOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSignatureThumbprint() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setSignatureVerificationCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map properties=new HashMap(); properties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE); properties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); properties.put(WSHandlerConstants.SIG_PROP_FILE,"outsecurity.properties"); properties.put(WSHandlerConstants.USER,"myalias"); properties.put(WSHandlerConstants.SIG_KEY_ID,"Thumbprint"); WSS4JOutInterceptor ohandler=new WSS4JOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSignatureKeyValue() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setSignatureVerificationCryptoProperties(cryptoProperties); inProperties.addIgnoreBSPRule(BSPRule.R5417); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map properties=new HashMap(); properties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE); properties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); properties.put(WSHandlerConstants.SIG_PROP_FILE,"outsecurity.properties"); properties.put(WSHandlerConstants.USER,"myalias"); properties.put(WSHandlerConstants.SIG_KEY_ID,"KeyValue"); WSS4JOutInterceptor ohandler=new WSS4JOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

Class: org.apache.cxf.ws.security.wss4j.RoundTripTest

EqualityVerifier 
@Test public void testSignature() throws Exception { wsIn.setProperty(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE); wsOut.setProperty(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testEncryptionPlusSig() throws Exception { wsIn.setProperty(WSHandlerConstants.ACTION,WSHandlerConstants.ENCRYPT + " " + WSHandlerConstants.SIGNATURE); wsOut.setProperty(WSHandlerConstants.ACTION,WSHandlerConstants.ENCRYPT + " " + WSHandlerConstants.SIGNATURE); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testUsernameToken() throws Exception { String actions=WSHandlerConstants.ENCRYPT + " " + WSHandlerConstants.SIGNATURE+ " "+ WSHandlerConstants.TIMESTAMP+ " "+ WSHandlerConstants.USERNAME_TOKEN; wsIn.setProperty(WSHandlerConstants.ACTION,actions); wsOut.setProperty(WSHandlerConstants.ACTION,actions); assertEquals("test",echo.echo("test")); }

Class: org.apache.cxf.ws.security.wss4j.SecurityActionTokenTest

APIUtilityVerifier IdentityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testEncryption() throws Exception { EncryptionActionToken actionToken=new EncryptionActionToken(); actionToken.setCryptoProperties("outsecurity.properties"); actionToken.setUser("myalias"); List actions=Collections.singletonList(new HandlerAction(WSConstants.ENCR,actionToken)); Map outProperties=new HashMap(); outProperties.put(WSHandlerConstants.HANDLER_ACTIONS,actions); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.ENCRYPT); inProperties.put(WSHandlerConstants.DEC_PROP_FILE,"insecurity.properties"); inProperties.put(WSHandlerConstants.PW_CALLBACK_CLASS,"org.apache.cxf.ws.security.wss4j.TestPwdCallback"); List xpaths=new ArrayList(); xpaths.add("//wsse:Security"); xpaths.add("//s:Body/xenc:EncryptedData"); List handlerResults=getResults(makeInvocation(outProperties,xpaths,inProperties)); assertNotNull(handlerResults); assertSame(handlerResults.size(),1); final java.util.List protectionResults=handlerResults.get(0).getResults(); assertNotNull(protectionResults); assertSame(protectionResults.size(),1); final java.util.Map result=protectionResults.get(0); final java.util.List protectedElements=CastUtils.cast((List)result.get(WSSecurityEngineResult.TAG_DATA_REF_URIS)); assertNotNull(protectedElements); assertSame(protectedElements.size(),1); assertEquals(protectedElements.get(0).getName(),new javax.xml.namespace.QName("http://schemas.xmlsoap.org/soap/envelope/","Body")); }

Class: org.apache.cxf.ws.security.wss4j.StaxCryptoCoverageCheckerTest

EqualityVerifier 
@Test public void testEncryptSignature() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setSignatureVerificationCryptoProperties(cryptoProperties); inProperties.setDecryptionCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); StaxCryptoCoverageChecker checker=new StaxCryptoCoverageChecker(); service.getInInterceptors().add(checker); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.ENCRYPT); actions.add(WSSConstants.SIGNATURE); properties.setActions(actions); properties.setEncryptionUser("myalias"); properties.setSignatureUser("myalias"); properties.setEncryptionSymAlgorithm(WSSConstants.NS_XENC_AES128); Properties outCryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setSignatureCryptoProperties(outCryptoProperties); properties.setEncryptionCryptoProperties(outCryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSignatureTimestamp() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setSignatureVerificationCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); StaxCryptoCoverageChecker checker=new StaxCryptoCoverageChecker(); service.getInInterceptors().add(checker); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.TIMESTAMP); actions.add(WSSConstants.SIGNATURE); properties.setActions(actions); properties.addSignaturePart(new SecurePart(new QName(WSSConstants.NS_WSU10,"Timestamp"),SecurePart.Modifier.Element)); properties.addSignaturePart(new SecurePart(new QName(WSSConstants.NS_SOAP11,"Body"),SecurePart.Modifier.Element)); properties.setSignatureUser("myalias"); Properties outCryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setSignatureCryptoProperties(outCryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testEncryptUsernameToken() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setDecryptionCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); StaxCryptoCoverageChecker checker=new StaxCryptoCoverageChecker(); checker.setSignBody(false); checker.setEncryptUsernameToken(true); service.getInInterceptors().add(checker); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.USERNAMETOKEN); actions.add(WSSConstants.ENCRYPT); properties.setActions(actions); properties.addEncryptionPart(new SecurePart(new QName(WSSConstants.NS_WSSE10,"UsernameToken"),SecurePart.Modifier.Element)); properties.setEncryptionUser("myalias"); properties.setTokenUser("username"); properties.setEncryptionSymAlgorithm(WSSConstants.NS_XENC_AES128); Properties outCryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setEncryptionCryptoProperties(outCryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); checker.setSignUsernameToken(true); try { echo.echo("test"); fail("Failure expected as UsernameToken isn't signed"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { } }

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testTimestamp() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); StaxCryptoCoverageChecker checker=new StaxCryptoCoverageChecker(); checker.setSignBody(false); service.getInInterceptors().add(checker); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.TIMESTAMP); properties.setActions(actions); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); try { echo.echo("test"); fail("Failure expected as Timestamp isn't signed"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { } checker.setSignTimestamp(false); assertEquals("test",echo.echo("test")); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testSignature() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setSignatureVerificationCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); WSS4JPrincipalInterceptor principalInterceptor=new WSS4JPrincipalInterceptor(); principalInterceptor.setPrincipalName("CN=myAlias"); service.getInInterceptors().add(inhandler); service.getInInterceptors().add(principalInterceptor); StaxCryptoCoverageChecker checker=new StaxCryptoCoverageChecker(); service.getInInterceptors().add(checker); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.SIGNATURE); properties.setActions(actions); properties.setSignatureUser("myalias"); Properties outCryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setSignatureCryptoProperties(outCryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); checker.setEncryptBody(true); try { echo.echo("test"); fail("Failure expected as SOAP Body isn't encrypted"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { } }

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testEncryptedBody() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setDecryptionCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); StaxCryptoCoverageChecker checker=new StaxCryptoCoverageChecker(); service.getInInterceptors().add(checker); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.ENCRYPT); properties.setActions(actions); properties.setEncryptionUser("myalias"); properties.setEncryptionSymAlgorithm(WSSConstants.NS_XENC_AES128); Properties outCryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setEncryptionCryptoProperties(outCryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); try { echo.echo("test"); fail("Failure expected as SOAP Body isn't signed"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { } checker.setSignBody(false); assertEquals("test",echo.echo("test")); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testSignedUsernameToken() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setSignatureVerificationCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); StaxCryptoCoverageChecker checker=new StaxCryptoCoverageChecker(); checker.setSignBody(false); checker.setSignUsernameToken(true); service.getInInterceptors().add(checker); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.USERNAMETOKEN); actions.add(WSSConstants.SIGNATURE); properties.setActions(actions); properties.setSignatureUser("myalias"); properties.addSignaturePart(new SecurePart(new QName(WSSConstants.NS_WSSE10,"UsernameToken"),SecurePart.Modifier.Element)); properties.addSignaturePart(new SecurePart(new QName(WSSConstants.NS_SOAP11,"Body"),SecurePart.Modifier.Element)); Properties outCryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setSignatureCryptoProperties(outCryptoProperties); properties.setTokenUser("username"); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); checker.setEncryptUsernameToken(false); assertEquals("test",echo.echo("test")); checker.setEncryptUsernameToken(true); try { echo.echo("test"); fail("Failure expected as UsernameToken isn't encrypted"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { } }

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testUsernameToken() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); WSS4JPrincipalInterceptor principalInterceptor=new WSS4JPrincipalInterceptor(); principalInterceptor.setPrincipalName("username"); service.getInInterceptors().add(inhandler); service.getInInterceptors().add(principalInterceptor); StaxCryptoCoverageChecker checker=new StaxCryptoCoverageChecker(); checker.setSignBody(false); checker.setEncryptUsernameToken(true); service.getInInterceptors().add(checker); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.USERNAMETOKEN); properties.setActions(actions); properties.setUsernameTokenPasswordType(WSSConstants.UsernameTokenPasswordType.PASSWORD_TEXT); properties.setTokenUser("username"); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); try { echo.echo("test"); fail("Failure expected as UsernameToken isn't encrypted"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { } checker.setEncryptUsernameToken(false); assertEquals("test",echo.echo("test")); }

Class: org.apache.cxf.ws.security.wss4j.StaxRoundTripActionTest

EqualityVerifier 
@Test public void testSignatureTimestampConfig() throws Exception { Service service=createService(); Map inConfig=new HashMap(); inConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.TIMESTAMP + " " + ConfigurationConstants.SIGNATURE); inConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); inConfig.put(ConfigurationConstants.SIG_VER_PROP_FILE,"insecurity.properties"); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inConfig); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map outConfig=new HashMap(); outConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.TIMESTAMP + " " + ConfigurationConstants.SIGNATURE); outConfig.put(ConfigurationConstants.SIGNATURE_PARTS,"{Element}{" + WSSConstants.NS_WSU10 + "}Timestamp;"+ "{Element}{"+ WSSConstants.NS_SOAP11+ "}Body"); outConfig.put(ConfigurationConstants.SIGNATURE_USER,"myalias"); outConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); outConfig.put(ConfigurationConstants.SIG_PROP_FILE,"outsecurity.properties"); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(outConfig); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSignatureTimestamp() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); List actions=new ArrayList(); actions.add(WSSConstants.TIMESTAMP); actions.add(WSSConstants.SIGNATURE); inProperties.setActions(actions); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setSignatureVerificationCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); actions=new ArrayList(); actions.add(WSSConstants.TIMESTAMP); actions.add(WSSConstants.SIGNATURE); properties.setActions(actions); properties.addSignaturePart(new SecurePart(new QName(WSSConstants.NS_WSU10,"Timestamp"),SecurePart.Modifier.Element)); properties.addSignaturePart(new SecurePart(new QName(WSSConstants.NS_SOAP11,"Body"),SecurePart.Modifier.Element)); properties.setSignatureUser("myalias"); Properties outCryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setSignatureCryptoProperties(outCryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

UtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testSignature() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); List actions=new ArrayList(); actions.add(WSSConstants.SIGNATURE); inProperties.setActions(actions); inProperties.setSignatureVerificationCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); WSS4JPrincipalInterceptor principalInterceptor=new WSS4JPrincipalInterceptor(); principalInterceptor.setPrincipalName("CN=myAlias"); service.getInInterceptors().add(inhandler); service.getInInterceptors().add(principalInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); actions=new ArrayList(); actions.add(WSSConstants.SIGNATURE); properties.setActions(actions); properties.setSignatureUser("myalias"); Properties outCryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setSignatureCryptoProperties(outCryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); actions=new ArrayList(); actions.add(WSSConstants.SIGNATURE); actions.add(WSSConstants.ENCRYPT); inProperties.setActions(actions); try { echo.echo("test"); fail("Failure expected on the wrong action"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { assertTrue(ex.getMessage().contains(WSSecurityException.UNIFIED_SECURITY_ERR)); } }

UtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testUsernameTokenConfig() throws Exception { Service service=createService(); Map inConfig=new HashMap(); inConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.USERNAME_TOKEN); inConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); inConfig.put(ConfigurationConstants.PASSWORD_TYPE,"PasswordText"); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inConfig); WSS4JPrincipalInterceptor principalInterceptor=new WSS4JPrincipalInterceptor(); principalInterceptor.setPrincipalName("username"); service.getInInterceptors().add(inhandler); service.getInInterceptors().add(principalInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.USERNAMETOKEN); properties.setActions(actions); properties.setUsernameTokenPasswordType(WSSConstants.UsernameTokenPasswordType.PASSWORD_TEXT); properties.setTokenUser("username"); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); service.getInInterceptors().remove(inhandler); inConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.USERNAME_TOKEN + " " + ConfigurationConstants.ENCRYPT); inhandler=new WSS4JStaxInInterceptor(inConfig); service.getInInterceptors().add(inhandler); try { echo.echo("test"); fail("Failure expected on the wrong action"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { assertTrue(ex.getMessage().contains(WSSecurityException.UNIFIED_SECURITY_ERR)); } }

EqualityVerifier 
@Test public void testEncryptUsernameToken() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); List actions=new ArrayList(); actions.add(WSSConstants.ENCRYPT); actions.add(WSSConstants.USERNAMETOKEN); inProperties.setActions(actions); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setDecryptionCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); actions=new ArrayList(); actions.add(WSSConstants.USERNAMETOKEN); actions.add(WSSConstants.ENCRYPT); properties.setActions(actions); properties.addEncryptionPart(new SecurePart(new QName(WSSConstants.NS_WSSE10,"UsernameToken"),SecurePart.Modifier.Element)); properties.setEncryptionUser("myalias"); properties.setTokenUser("username"); properties.setEncryptionSymAlgorithm(WSSConstants.NS_XENC_AES128); Properties outCryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setEncryptionCryptoProperties(outCryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testEncryptSignatureConfig() throws Exception { Service service=createService(); Map inConfig=new HashMap(); inConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.ENCRYPT + " " + ConfigurationConstants.SIGNATURE); inConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); inConfig.put(ConfigurationConstants.SIG_VER_PROP_FILE,"insecurity.properties"); inConfig.put(ConfigurationConstants.DEC_PROP_FILE,"insecurity.properties"); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inConfig); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map outConfig=new HashMap(); outConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.ENCRYPT + " " + ConfigurationConstants.SIGNATURE); outConfig.put(ConfigurationConstants.SIGNATURE_USER,"myalias"); outConfig.put(ConfigurationConstants.ENCRYPTION_USER,"myalias"); outConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); outConfig.put(ConfigurationConstants.SIG_PROP_FILE,"outsecurity.properties"); outConfig.put(ConfigurationConstants.ENC_PROP_FILE,"outsecurity.properties"); outConfig.put(ConfigurationConstants.ENC_SYM_ALGO,WSSConstants.NS_XENC_AES128); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(outConfig); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

UtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testUsernameToken() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.USERNAMETOKEN); inProperties.setActions(actions); inProperties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); WSS4JPrincipalInterceptor principalInterceptor=new WSS4JPrincipalInterceptor(); principalInterceptor.setPrincipalName("username"); service.getInInterceptors().add(inhandler); service.getInInterceptors().add(principalInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); actions=new ArrayList(); actions.add(WSSConstants.USERNAMETOKEN); properties.setActions(actions); properties.setUsernameTokenPasswordType(WSSConstants.UsernameTokenPasswordType.PASSWORD_TEXT); properties.setTokenUser("username"); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); actions=new ArrayList(); actions.add(WSSConstants.USERNAMETOKEN); actions.add(WSSConstants.ENCRYPT); inProperties.setActions(actions); try { echo.echo("test"); fail("Failure expected on the wrong action"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { assertTrue(ex.getMessage().contains(WSSecurityException.UNIFIED_SECURITY_ERR)); } }

UtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testEncryptConfig() throws Exception { Service service=createService(); Map inConfig=new HashMap(); inConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.ENCRYPT); inConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); inConfig.put(ConfigurationConstants.DEC_PROP_FILE,"insecurity.properties"); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inConfig); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map outConfig=new HashMap(); outConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.ENCRYPT); outConfig.put(ConfigurationConstants.ENCRYPTION_USER,"myalias"); outConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); outConfig.put(ConfigurationConstants.ENC_PROP_FILE,"outsecurity.properties"); outConfig.put(ConfigurationConstants.ENC_SYM_ALGO,WSSConstants.NS_XENC_AES128); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(outConfig); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); service.getInInterceptors().remove(inhandler); inConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.ENCRYPT + " " + ConfigurationConstants.SIGNATURE); inhandler=new WSS4JStaxInInterceptor(inConfig); service.getInInterceptors().add(inhandler); try { echo.echo("test"); fail("Failure expected on the wrong action"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { assertTrue(ex.getMessage().contains(WSSecurityException.UNIFIED_SECURITY_ERR)); } }

EqualityVerifier 
@Test public void testEncryptUsernameTokenConfig() throws Exception { Service service=createService(); Map inConfig=new HashMap(); inConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.ENCRYPT + " " + ConfigurationConstants.USERNAME_TOKEN); inConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); inConfig.put(ConfigurationConstants.DEC_PROP_FILE,"insecurity.properties"); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inConfig); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map outConfig=new HashMap(); outConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.USERNAME_TOKEN + " " + ConfigurationConstants.ENCRYPT); outConfig.put(ConfigurationConstants.ENCRYPTION_PARTS,"{Element}{" + WSSConstants.NS_WSSE10 + "}UsernameToken"); outConfig.put(ConfigurationConstants.USER,"username"); outConfig.put(ConfigurationConstants.ENCRYPTION_USER,"myalias"); outConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); outConfig.put(ConfigurationConstants.ENC_PROP_FILE,"outsecurity.properties"); outConfig.put(ConfigurationConstants.ENC_SYM_ALGO,WSSConstants.NS_XENC_AES128); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(outConfig); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testTimestamp() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.TIMESTAMP); inProperties.setActions(actions); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); actions=new ArrayList(); actions.add(WSSConstants.TIMESTAMP); properties.setActions(actions); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testTimestampConfig() throws Exception { Service service=createService(); Map inConfig=new HashMap(); inConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.TIMESTAMP); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inConfig); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map outConfig=new HashMap(); outConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.TIMESTAMP); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(outConfig); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

UtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testEncrypt() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); List actions=new ArrayList(); actions.add(WSSConstants.ENCRYPT); inProperties.setActions(actions); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setDecryptionCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); actions=new ArrayList(); actions.add(WSSConstants.ENCRYPT); properties.setActions(actions); properties.setEncryptionUser("myalias"); properties.setEncryptionSymAlgorithm(WSSConstants.NS_XENC_AES128); Properties outCryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setEncryptionCryptoProperties(outCryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); actions=new ArrayList(); actions.add(WSSConstants.ENCRYPT); actions.add(WSSConstants.SIGNATURE); inProperties.setActions(actions); try { echo.echo("test"); fail("Failure expected on the wrong action"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { assertTrue(ex.getMessage().contains(WSSecurityException.UNIFIED_SECURITY_ERR)); } }

EqualityVerifier 
@Test public void testEncryptSignature() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); List actions=new ArrayList(); actions.add(WSSConstants.ENCRYPT); actions.add(WSSConstants.SIGNATURE); inProperties.setActions(actions); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setSignatureVerificationCryptoProperties(cryptoProperties); inProperties.setDecryptionCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); actions=new ArrayList(); actions.add(WSSConstants.ENCRYPT); actions.add(WSSConstants.SIGNATURE); properties.setActions(actions); properties.setEncryptionUser("myalias"); properties.setSignatureUser("myalias"); properties.setEncryptionSymAlgorithm(WSSConstants.NS_XENC_AES128); Properties outCryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setSignatureCryptoProperties(outCryptoProperties); properties.setEncryptionCryptoProperties(outCryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

UtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testSignatureConfig() throws Exception { Service service=createService(); Map inConfig=new HashMap(); inConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.SIGNATURE); inConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); inConfig.put(ConfigurationConstants.SIG_VER_PROP_FILE,"insecurity.properties"); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inConfig); WSS4JPrincipalInterceptor principalInterceptor=new WSS4JPrincipalInterceptor(); principalInterceptor.setPrincipalName("CN=myAlias"); service.getInInterceptors().add(inhandler); service.getInInterceptors().add(principalInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map outConfig=new HashMap(); outConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.SIGNATURE); outConfig.put(ConfigurationConstants.SIGNATURE_USER,"myalias"); outConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); outConfig.put(ConfigurationConstants.SIG_PROP_FILE,"outsecurity.properties"); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(outConfig); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); service.getInInterceptors().remove(inhandler); inConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.SIGNATURE + " " + ConfigurationConstants.ENCRYPT); inhandler=new WSS4JStaxInInterceptor(inConfig); service.getInInterceptors().add(inhandler); try { echo.echo("test"); fail("Failure expected on the wrong action"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { assertTrue(ex.getMessage().contains(WSSecurityException.UNIFIED_SECURITY_ERR)); } }

Class: org.apache.cxf.ws.security.wss4j.StaxRoundTripTest

EqualityVerifier 
@Test public void testEncryptUsernameToken() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setDecryptionCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.USERNAMETOKEN); actions.add(WSSConstants.ENCRYPT); properties.setActions(actions); properties.addEncryptionPart(new SecurePart(new QName(WSSConstants.NS_WSSE10,"UsernameToken"),SecurePart.Modifier.Element)); properties.setEncryptionUser("myalias"); properties.setTokenUser("username"); properties.setEncryptionSymAlgorithm(WSSConstants.NS_XENC_AES128); Properties outCryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setEncryptionCryptoProperties(outCryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testTimestamp() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.TIMESTAMP); properties.setActions(actions); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

UtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testUsernameTokenDigest() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); inProperties.setUsernameTokenPasswordType(WSSConstants.UsernameTokenPasswordType.PASSWORD_DIGEST); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); WSS4JPrincipalInterceptor principalInterceptor=new WSS4JPrincipalInterceptor(); principalInterceptor.setPrincipalName("username"); service.getInInterceptors().add(inhandler); service.getInInterceptors().add(principalInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.USERNAMETOKEN); properties.setActions(actions); properties.setUsernameTokenPasswordType(WSSConstants.UsernameTokenPasswordType.PASSWORD_DIGEST); properties.setTokenUser("username"); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); service.getInInterceptors().remove(inhandler); inProperties.setUsernameTokenPasswordType(WSSConstants.UsernameTokenPasswordType.PASSWORD_TEXT); inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); service.put(SecurityConstants.RETURN_SECURITY_ERROR,true); try { echo.echo("test"); fail("Failure expected on the wrong password type"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { String error="The security token could not be authenticated or authorized"; assertTrue(ex.getMessage().contains(error)); } }

EqualityVerifier 
@Test public void testSignatureConfirmation() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setSignatureVerificationCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); WSSSecurityProperties outProperties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.SIGNATURE); actions.add(WSSConstants.SIGNATURE_CONFIRMATION); outProperties.setActions(actions); outProperties.setSignatureUser("myalias"); Properties outCryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); outProperties.setSignatureCryptoProperties(outCryptoProperties); outProperties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor staxOhandler=new WSS4JStaxOutInterceptor(outProperties); service.getOutInterceptors().add(staxOhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); actions=new ArrayList(); actions.add(WSSConstants.SIGNATURE); properties.setActions(actions); properties.setSignatureUser("myalias"); Properties clientOutCryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setSignatureCryptoProperties(clientOutCryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); WSSSecurityProperties staxInProperties=new WSSSecurityProperties(); staxInProperties.setCallbackHandler(new TestPwdCallback()); Properties staxInCryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); staxInProperties.setSignatureVerificationCryptoProperties(staxInCryptoProperties); staxInProperties.setEnableSignatureConfirmationVerification(true); WSS4JStaxInInterceptor inhandler2=new WSS4JStaxInInterceptor(staxInProperties); client.getInInterceptors().add(inhandler2); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSignatureConfig() throws Exception { Service service=createService(); Map inConfig=new HashMap(); inConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); inConfig.put(ConfigurationConstants.SIG_VER_PROP_FILE,"insecurity.properties"); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inConfig); WSS4JPrincipalInterceptor principalInterceptor=new WSS4JPrincipalInterceptor(); principalInterceptor.setPrincipalName("CN=myAlias"); service.getInInterceptors().add(inhandler); service.getInInterceptors().add(principalInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map outConfig=new HashMap(); outConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.SIGNATURE); outConfig.put(ConfigurationConstants.SIGNATURE_USER,"myalias"); outConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); outConfig.put(ConfigurationConstants.SIG_PROP_FILE,"outsecurity.properties"); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(outConfig); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSignedUsernameTokenConfig() throws Exception { Service service=createService(); Map inConfig=new HashMap(); inConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); inConfig.put(ConfigurationConstants.SIG_VER_PROP_FILE,"insecurity.properties"); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inConfig); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map outConfig=new HashMap(); outConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.USERNAME_TOKEN + " " + ConfigurationConstants.SIGNATURE); outConfig.put(ConfigurationConstants.SIGNATURE_PARTS,"{Element}{" + WSSConstants.NS_WSSE10 + "}UsernameToken;"+ "{Element}{"+ WSSConstants.NS_SOAP11+ "}Body"); outConfig.put(ConfigurationConstants.USER,"username"); outConfig.put(ConfigurationConstants.SIGNATURE_USER,"myalias"); outConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); outConfig.put(ConfigurationConstants.SIG_PROP_FILE,"outsecurity.properties"); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(outConfig); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSignatureTimestampConfig() throws Exception { Service service=createService(); Map inConfig=new HashMap(); inConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); inConfig.put(ConfigurationConstants.SIG_VER_PROP_FILE,"insecurity.properties"); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inConfig); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map outConfig=new HashMap(); outConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.TIMESTAMP + " " + ConfigurationConstants.SIGNATURE); outConfig.put(ConfigurationConstants.SIGNATURE_PARTS,"{Element}{" + WSSConstants.NS_WSU10 + "}Timestamp;"+ "{Element}{"+ WSSConstants.NS_SOAP11+ "}Body"); outConfig.put(ConfigurationConstants.SIGNATURE_USER,"myalias"); outConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); outConfig.put(ConfigurationConstants.SIG_PROP_FILE,"outsecurity.properties"); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(outConfig); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testEncryptUsernameTokenConfig() throws Exception { Service service=createService(); Map inConfig=new HashMap(); inConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); inConfig.put(ConfigurationConstants.DEC_PROP_FILE,"insecurity.properties"); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inConfig); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map outConfig=new HashMap(); outConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.USERNAME_TOKEN + " " + ConfigurationConstants.ENCRYPT); outConfig.put(ConfigurationConstants.ENCRYPTION_PARTS,"{Element}{" + WSSConstants.NS_WSSE10 + "}UsernameToken"); outConfig.put(ConfigurationConstants.USER,"username"); outConfig.put(ConfigurationConstants.ENCRYPTION_USER,"myalias"); outConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); outConfig.put(ConfigurationConstants.ENC_PROP_FILE,"outsecurity.properties"); outConfig.put(ConfigurationConstants.ENC_SYM_ALGO,WSSConstants.NS_XENC_AES128); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(outConfig); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testTimestampConfig() throws Exception { Service service=createService(); Map inConfig=new HashMap(); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inConfig); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map outConfig=new HashMap(); outConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.TIMESTAMP); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(outConfig); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testEncryptSignature() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setSignatureVerificationCryptoProperties(cryptoProperties); inProperties.setDecryptionCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.ENCRYPT); actions.add(WSSConstants.SIGNATURE); properties.setActions(actions); properties.setEncryptionUser("myalias"); properties.setSignatureUser("myalias"); properties.setEncryptionSymAlgorithm(WSSConstants.NS_XENC_AES128); Properties outCryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setSignatureCryptoProperties(outCryptoProperties); properties.setEncryptionCryptoProperties(outCryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSignature() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setSignatureVerificationCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); WSS4JPrincipalInterceptor principalInterceptor=new WSS4JPrincipalInterceptor(); principalInterceptor.setPrincipalName("CN=myAlias"); service.getInInterceptors().add(inhandler); service.getInInterceptors().add(principalInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.SIGNATURE); properties.setActions(actions); properties.setSignatureUser("myalias"); Properties outCryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setSignatureCryptoProperties(outCryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSignaturePKI() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); Properties cryptoProperties=CryptoFactory.getProperties("cxfca.properties",this.getClass().getClassLoader()); inProperties.setSignatureVerificationCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); WSS4JPrincipalInterceptor principalInterceptor=new WSS4JPrincipalInterceptor(); principalInterceptor.setPrincipalName("CN=alice,OU=eng,O=apache.org"); service.getInInterceptors().add(inhandler); service.getInInterceptors().add(principalInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.SIGNATURE); properties.setActions(actions); properties.setSignatureUser("alice"); Properties outCryptoProperties=CryptoFactory.getProperties("alice.properties",this.getClass().getClassLoader()); properties.setSignatureCryptoProperties(outCryptoProperties); properties.setCallbackHandler(new KeystorePasswordCallback()); properties.setUseSingleCert(true); properties.setSignatureKeyIdentifier(WSSecurityTokenConstants.KEYIDENTIFIER_SECURITY_TOKEN_DIRECT_REFERENCE); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

UtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testUsernameTokenTextConfig() throws Exception { Service service=createService(); Map inConfig=new HashMap(); inConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); inConfig.put(ConfigurationConstants.PASSWORD_TYPE,"PasswordText"); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inConfig); WSS4JPrincipalInterceptor principalInterceptor=new WSS4JPrincipalInterceptor(); principalInterceptor.setPrincipalName("username"); service.getInInterceptors().add(inhandler); service.getInInterceptors().add(principalInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map outConfig=new HashMap(); outConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.USERNAME_TOKEN); outConfig.put(ConfigurationConstants.PASSWORD_TYPE,"PasswordText"); outConfig.put(ConfigurationConstants.USER,"username"); outConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(outConfig); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); service.getInInterceptors().remove(inhandler); inConfig.put(ConfigurationConstants.PASSWORD_TYPE,"PasswordDigest"); inhandler=new WSS4JStaxInInterceptor(inConfig); service.getInInterceptors().add(inhandler); service.put(SecurityConstants.RETURN_SECURITY_ERROR,true); try { echo.echo("test"); fail("Failure expected on the wrong password type"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { String error="The security token could not be authenticated or authorized"; assertTrue(ex.getMessage().contains(error)); } }

EqualityVerifier 
@Test public void testEncryptSignatureConfig() throws Exception { Service service=createService(); Map inConfig=new HashMap(); inConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); inConfig.put(ConfigurationConstants.SIG_VER_PROP_FILE,"insecurity.properties"); inConfig.put(ConfigurationConstants.DEC_PROP_FILE,"insecurity.properties"); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inConfig); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map outConfig=new HashMap(); outConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.ENCRYPT + " " + ConfigurationConstants.SIGNATURE); outConfig.put(ConfigurationConstants.SIGNATURE_USER,"myalias"); outConfig.put(ConfigurationConstants.ENCRYPTION_USER,"myalias"); outConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); outConfig.put(ConfigurationConstants.SIG_PROP_FILE,"outsecurity.properties"); outConfig.put(ConfigurationConstants.ENC_PROP_FILE,"outsecurity.properties"); outConfig.put(ConfigurationConstants.ENC_SYM_ALGO,WSSConstants.NS_XENC_AES128); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(outConfig); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testEncrypt() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setDecryptionCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.ENCRYPT); properties.setActions(actions); properties.setEncryptionSymAlgorithm(WSSConstants.NS_XENC_AES128); properties.setEncryptionUser("myalias"); Properties outCryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setEncryptionCryptoProperties(outCryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSignatureConfirmationConfig() throws Exception { Service service=createService(); Map inConfig=new HashMap(); inConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); inConfig.put(ConfigurationConstants.SIG_VER_PROP_FILE,"insecurity.properties"); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inConfig); service.getInInterceptors().add(inhandler); Map outConfig=new HashMap(); outConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.SIGNATURE); outConfig.put(ConfigurationConstants.SIGNATURE_USER,"myalias"); outConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); outConfig.put(ConfigurationConstants.ENABLE_SIGNATURE_CONFIRMATION,"true"); outConfig.put(ConfigurationConstants.SIG_PROP_FILE,"outsecurity.properties"); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(outConfig); service.getOutInterceptors().add(ohandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map clientOutConfig=new HashMap(); clientOutConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.SIGNATURE); clientOutConfig.put(ConfigurationConstants.SIGNATURE_USER,"myalias"); clientOutConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); clientOutConfig.put(ConfigurationConstants.SIG_PROP_FILE,"outsecurity.properties"); WSS4JStaxOutInterceptor clientOhandler=new WSS4JStaxOutInterceptor(clientOutConfig); client.getOutInterceptors().add(clientOhandler); Map clientInConfig=new HashMap(); clientInConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); clientInConfig.put(ConfigurationConstants.ENABLE_SIGNATURE_CONFIRMATION,"true"); clientInConfig.put(ConfigurationConstants.SIG_VER_PROP_FILE,"insecurity.properties"); WSS4JStaxInInterceptor clientInHandler=new WSS4JStaxInInterceptor(clientInConfig); client.getInInterceptors().add(clientInHandler); assertEquals("test",echo.echo("test")); }

UtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testUsernameTokenDigestConfig() throws Exception { Service service=createService(); Map inConfig=new HashMap(); inConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); inConfig.put(ConfigurationConstants.PASSWORD_TYPE,"PasswordDigest"); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inConfig); WSS4JPrincipalInterceptor principalInterceptor=new WSS4JPrincipalInterceptor(); principalInterceptor.setPrincipalName("username"); service.getInInterceptors().add(inhandler); service.getInInterceptors().add(principalInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map outConfig=new HashMap(); outConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.USERNAME_TOKEN); outConfig.put(ConfigurationConstants.PASSWORD_TYPE,"PasswordDigest"); outConfig.put(ConfigurationConstants.USER,"username"); outConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(outConfig); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); service.getInInterceptors().remove(inhandler); inConfig.put(ConfigurationConstants.PASSWORD_TYPE,"PasswordText"); inhandler=new WSS4JStaxInInterceptor(inConfig); service.getInInterceptors().add(inhandler); service.put(SecurityConstants.RETURN_SECURITY_ERROR,true); try { echo.echo("test"); fail("Failure expected on the wrong password type"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { String error="The security token could not be authenticated or authorized"; assertTrue(ex.getMessage().contains(error)); } }

EqualityVerifier 
@Test public void testSignatureTimestamp() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setSignatureVerificationCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.TIMESTAMP); actions.add(WSSConstants.SIGNATURE); properties.setActions(actions); properties.addSignaturePart(new SecurePart(new QName(WSSConstants.NS_WSU10,"Timestamp"),SecurePart.Modifier.Element)); properties.addSignaturePart(new SecurePart(new QName(WSSConstants.NS_SOAP11,"Body"),SecurePart.Modifier.Element)); properties.setSignatureUser("myalias"); Properties outCryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setSignatureCryptoProperties(outCryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSignedUsernameToken() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setSignatureVerificationCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.USERNAMETOKEN); actions.add(WSSConstants.SIGNATURE); properties.setActions(actions); properties.setSignatureUser("myalias"); properties.addSignaturePart(new SecurePart(new QName(WSSConstants.NS_WSSE10,"UsernameToken"),SecurePart.Modifier.Element)); properties.addSignaturePart(new SecurePart(new QName(WSSConstants.NS_SOAP11,"Body"),SecurePart.Modifier.Element)); Properties outCryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setSignatureCryptoProperties(outCryptoProperties); properties.setTokenUser("username"); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

UtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testUsernameTokenText() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); inProperties.setUsernameTokenPasswordType(WSSConstants.UsernameTokenPasswordType.PASSWORD_TEXT); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); WSS4JPrincipalInterceptor principalInterceptor=new WSS4JPrincipalInterceptor(); principalInterceptor.setPrincipalName("username"); service.getInInterceptors().add(inhandler); service.getInInterceptors().add(principalInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.USERNAMETOKEN); properties.setActions(actions); properties.setUsernameTokenPasswordType(WSSConstants.UsernameTokenPasswordType.PASSWORD_TEXT); properties.setTokenUser("username"); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); service.getInInterceptors().remove(inhandler); inProperties.setUsernameTokenPasswordType(WSSConstants.UsernameTokenPasswordType.PASSWORD_DIGEST); inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); service.put(SecurityConstants.RETURN_SECURITY_ERROR,true); try { echo.echo("test"); fail("Failure expected on the wrong password type"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { String error="The security token could not be authenticated or authorized"; assertTrue(ex.getMessage().contains(error)); } }

EqualityVerifier 
@Test public void testEncryptConfig() throws Exception { Service service=createService(); Map inConfig=new HashMap(); inConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); inConfig.put(ConfigurationConstants.DEC_PROP_FILE,"insecurity.properties"); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inConfig); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map outConfig=new HashMap(); outConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.ENCRYPT); outConfig.put(ConfigurationConstants.ENCRYPTION_USER,"myalias"); outConfig.put(ConfigurationConstants.ENC_SYM_ALGO,WSSConstants.NS_XENC_AES128); outConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); outConfig.put(ConfigurationConstants.ENC_PROP_FILE,"outsecurity.properties"); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(outConfig); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSignaturePKIConfig() throws Exception { Service service=createService(); Map inConfig=new HashMap(); inConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); inConfig.put(ConfigurationConstants.SIG_VER_PROP_FILE,"cxfca.properties"); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inConfig); WSS4JPrincipalInterceptor principalInterceptor=new WSS4JPrincipalInterceptor(); principalInterceptor.setPrincipalName("CN=alice,OU=eng,O=apache.org"); service.getInInterceptors().add(inhandler); service.getInInterceptors().add(principalInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map outConfig=new HashMap(); outConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.SIGNATURE); outConfig.put(ConfigurationConstants.SIGNATURE_USER,"alice"); outConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new KeystorePasswordCallback()); outConfig.put(ConfigurationConstants.SIG_PROP_FILE,"alice.properties"); outConfig.put(ConfigurationConstants.USE_SINGLE_CERTIFICATE,"true"); outConfig.put(ConfigurationConstants.SIG_KEY_ID,"DirectReference"); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(outConfig); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

Class: org.apache.cxf.ws.security.wss4j.StaxToDOMEncryptionIdentifierTest

EqualityVerifier 
@Test public void testEncryptThumbprint() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.ENCRYPT); inProperties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); inProperties.put(WSHandlerConstants.DEC_PROP_FILE,"insecurity.properties"); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.ENCRYPT); properties.setActions(actions); properties.setEncryptionUser("myalias"); properties.setEncryptionKeyIdentifier(WSSecurityTokenConstants.KEYIDENTIFIER_THUMBPRINT_IDENTIFIER); properties.setEncryptionSymAlgorithm(WSSConstants.NS_XENC_AES128); Properties cryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setEncryptionCryptoProperties(cryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testEncryptEncryptedKeySHA1() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.ENCRYPT); inProperties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); inProperties.put(WSHandlerConstants.DEC_PROP_FILE,"insecurity.properties"); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.ENCRYPT); properties.setActions(actions); properties.setEncryptionUser("myalias"); properties.setEncryptionKeyIdentifier(WSSecurityTokenConstants.KEYIDENTIFIER_ENCRYPTED_KEY_SHA1_IDENTIFIER); properties.setEncryptionSymAlgorithm(WSSConstants.NS_XENC_AES128); Properties cryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setEncryptionCryptoProperties(cryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testEncryptDirectReference() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.ENCRYPT); inProperties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); inProperties.put(WSHandlerConstants.DEC_PROP_FILE,"insecurity.properties"); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.ENCRYPT); properties.setActions(actions); properties.setEncryptionUser("myalias"); properties.setEncryptionKeyIdentifier(WSSecurityTokenConstants.KEYIDENTIFIER_SECURITY_TOKEN_DIRECT_REFERENCE); properties.setEncryptionSymAlgorithm(WSSConstants.NS_XENC_AES128); Properties cryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setEncryptionCryptoProperties(cryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testEncryptX509() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.ENCRYPT); inProperties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); inProperties.put(WSHandlerConstants.DEC_PROP_FILE,"insecurity.properties"); inProperties.put(WSHandlerConstants.IS_BSP_COMPLIANT,"false"); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.ENCRYPT); properties.setActions(actions); properties.setEncryptionUser("myalias"); properties.setEncryptionKeyIdentifier(WSSecurityTokenConstants.KeyIdentifier_X509KeyIdentifier); properties.setEncryptionSymAlgorithm(WSSConstants.NS_XENC_AES128); Properties cryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setEncryptionCryptoProperties(cryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testEncryptIssuerSerial() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.ENCRYPT); inProperties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); inProperties.put(WSHandlerConstants.DEC_PROP_FILE,"insecurity.properties"); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.ENCRYPT); properties.setActions(actions); properties.setEncryptionUser("myalias"); properties.setEncryptionKeyIdentifier(WSSecurityTokenConstants.KeyIdentifier_IssuerSerial); properties.setEncryptionSymAlgorithm(WSSConstants.NS_XENC_AES128); Properties cryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setEncryptionCryptoProperties(cryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

Class: org.apache.cxf.ws.security.wss4j.StaxToDOMRoundTripTest

EqualityVerifier 
@Test public void testSignaturePKIConfig() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE); inProperties.put(WSHandlerConstants.PW_CALLBACK_REF,new KeystorePasswordCallback()); inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE,"cxfca.properties"); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map outConfig=new HashMap(); outConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.SIGNATURE); outConfig.put(ConfigurationConstants.SIGNATURE_USER,"alice"); outConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new KeystorePasswordCallback()); outConfig.put(ConfigurationConstants.SIG_PROP_FILE,"alice.properties"); outConfig.put(ConfigurationConstants.USE_SINGLE_CERTIFICATE,"true"); outConfig.put(ConfigurationConstants.SIG_KEY_ID,"DirectReference"); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(outConfig); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

UtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testUsernameTokenText() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.USERNAME_TOKEN); inProperties.put(WSHandlerConstants.PASSWORD_TYPE,WSConstants.PW_TEXT); inProperties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.USERNAMETOKEN); properties.setActions(actions); properties.setUsernameTokenPasswordType(WSSConstants.UsernameTokenPasswordType.PASSWORD_TEXT); properties.setTokenUser("username"); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); service.getInInterceptors().remove(inInterceptor); inProperties.put(WSHandlerConstants.PASSWORD_TYPE,WSConstants.PW_DIGEST); inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); service.put(SecurityConstants.RETURN_SECURITY_ERROR,true); try { echo.echo("test"); fail("Failure expected on the wrong password type"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { String error="The security token could not be authenticated or authorized"; assertTrue(ex.getMessage().contains(error)); } }

EqualityVerifier 
@Test public void testSignatureConfig() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE); inProperties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE,"insecurity.properties"); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map outConfig=new HashMap(); outConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.SIGNATURE); outConfig.put(ConfigurationConstants.SIGNATURE_USER,"myalias"); outConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); outConfig.put(ConfigurationConstants.SIG_PROP_FILE,"outsecurity.properties"); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(outConfig); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testEncryptConfig() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.ENCRYPT); inProperties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); inProperties.put(WSHandlerConstants.DEC_PROP_FILE,"insecurity.properties"); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map outConfig=new HashMap(); outConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.ENCRYPT); outConfig.put(ConfigurationConstants.ENCRYPTION_USER,"myalias"); outConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); outConfig.put(ConfigurationConstants.ENC_PROP_FILE,"outsecurity.properties"); outConfig.put(ConfigurationConstants.ENC_SYM_ALGO,WSSConstants.NS_XENC_AES128); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(outConfig); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSignedUsernameToken() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.USERNAME_TOKEN); inProperties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE,"insecurity.properties"); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.USERNAMETOKEN); actions.add(WSSConstants.SIGNATURE); properties.setActions(actions); properties.setSignatureUser("myalias"); properties.addSignaturePart(new SecurePart(new QName(WSSConstants.NS_WSSE10,"UsernameToken"),SecurePart.Modifier.Element)); properties.addSignaturePart(new SecurePart(new QName(WSSConstants.NS_SOAP11,"Body"),SecurePart.Modifier.Element)); Properties cryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setSignatureCryptoProperties(cryptoProperties); properties.setTokenUser("username"); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testEncrypt() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.ENCRYPT); inProperties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); inProperties.put(WSHandlerConstants.DEC_PROP_FILE,"insecurity.properties"); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.ENCRYPT); properties.setActions(actions); properties.setEncryptionUser("myalias"); properties.setEncryptionSymAlgorithm(WSSConstants.NS_XENC_AES128); Properties cryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setEncryptionCryptoProperties(cryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testEncryptSignatureConfig() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.ENCRYPT); inProperties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE,"insecurity.properties"); inProperties.put(WSHandlerConstants.DEC_PROP_FILE,"insecurity.properties"); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map outConfig=new HashMap(); outConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.ENCRYPT + " " + ConfigurationConstants.SIGNATURE); outConfig.put(ConfigurationConstants.SIGNATURE_USER,"myalias"); outConfig.put(ConfigurationConstants.ENCRYPTION_USER,"myalias"); outConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); outConfig.put(ConfigurationConstants.SIG_PROP_FILE,"outsecurity.properties"); outConfig.put(ConfigurationConstants.ENC_PROP_FILE,"outsecurity.properties"); outConfig.put(ConfigurationConstants.ENC_SYM_ALGO,WSSConstants.NS_XENC_AES128); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(outConfig); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testEncryptionAlgorithms() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.ENCRYPT); inProperties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); inProperties.put(WSHandlerConstants.DEC_PROP_FILE,"insecurity.properties"); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.ENCRYPT); properties.setActions(actions); properties.setEncryptionUser("myalias"); Properties cryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setEncryptionCryptoProperties(cryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); properties.setEncryptionKeyTransportAlgorithm("http://www.w3.org/2001/04/xmlenc#rsa-1_5"); properties.setEncryptionSymAlgorithm("http://www.w3.org/2001/04/xmlenc#tripledes-cbc"); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); try { echo.echo("test"); fail("Failure expected as RSA v1.5 is not allowed by default"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { } inProperties.put(WSHandlerConstants.ALLOW_RSA15_KEY_TRANSPORT_ALGORITHM,"true"); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testEncryptUsernameTokenConfig() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.USERNAME_TOKEN + " " + WSHandlerConstants.ENCRYPT); inProperties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); inProperties.put(WSHandlerConstants.DEC_PROP_FILE,"insecurity.properties"); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map outConfig=new HashMap(); outConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.USERNAME_TOKEN + " " + ConfigurationConstants.ENCRYPT); outConfig.put(ConfigurationConstants.ENCRYPTION_PARTS,"{Element}{" + WSSConstants.NS_WSSE10 + "}UsernameToken"); outConfig.put(ConfigurationConstants.USER,"username"); outConfig.put(ConfigurationConstants.ENCRYPTION_USER,"myalias"); outConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); outConfig.put(ConfigurationConstants.ENC_PROP_FILE,"outsecurity.properties"); outConfig.put(ConfigurationConstants.ENC_SYM_ALGO,WSSConstants.NS_XENC_AES128); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(outConfig); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

UtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testUsernameTokenTextConfig() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.USERNAME_TOKEN); inProperties.put(WSHandlerConstants.PASSWORD_TYPE,WSConstants.PW_TEXT); inProperties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map outConfig=new HashMap(); outConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.USERNAME_TOKEN); outConfig.put(ConfigurationConstants.PASSWORD_TYPE,"PasswordText"); outConfig.put(ConfigurationConstants.USER,"username"); outConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(outConfig); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); service.getInInterceptors().remove(inInterceptor); inProperties.put(WSHandlerConstants.PASSWORD_TYPE,WSConstants.PW_DIGEST); inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); service.put(SecurityConstants.RETURN_SECURITY_ERROR,true); try { echo.echo("test"); fail("Failure expected on the wrong password type"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { String error="The security token could not be authenticated or authorized"; assertTrue(ex.getMessage().contains(error)); } }

EqualityVerifier 
@Test public void testSignatureConfirmation() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE); inProperties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE,"insecurity.properties"); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Map outProperties=new HashMap(); outProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE); outProperties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); outProperties.put(WSHandlerConstants.SIG_PROP_FILE,"outsecurity.properties"); outProperties.put(WSHandlerConstants.ENABLE_SIGNATURE_CONFIRMATION,"true"); outProperties.put(WSHandlerConstants.USER,"myalias"); WSS4JOutInterceptor domOhandler=new WSS4JOutInterceptor(outProperties); service.getOutInterceptors().add(domOhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.SIGNATURE); properties.setActions(actions); properties.setSignatureUser("myalias"); Properties cryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setSignatureCryptoProperties(cryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); WSSSecurityProperties staxInProperties=new WSSSecurityProperties(); staxInProperties.setCallbackHandler(new TestPwdCallback()); Properties staxInCryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); staxInProperties.setSignatureVerificationCryptoProperties(staxInCryptoProperties); staxInProperties.setEnableSignatureConfirmationVerification(true); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(staxInProperties); client.getInInterceptors().add(inhandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSignedUsernameTokenConfig() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.USERNAME_TOKEN); inProperties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE,"insecurity.properties"); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map outConfig=new HashMap(); outConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.USERNAME_TOKEN + " " + ConfigurationConstants.SIGNATURE); outConfig.put(ConfigurationConstants.SIGNATURE_PARTS,"{Element}{" + WSSConstants.NS_WSSE10 + "}UsernameToken;"+ "{Element}{"+ WSSConstants.NS_SOAP11+ "}Body"); outConfig.put(ConfigurationConstants.USER,"username"); outConfig.put(ConfigurationConstants.SIGNATURE_USER,"myalias"); outConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); outConfig.put(ConfigurationConstants.SIG_PROP_FILE,"outsecurity.properties"); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(outConfig); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testEncryptionAlgorithmsConfig() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.ENCRYPT); inProperties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); inProperties.put(WSHandlerConstants.DEC_PROP_FILE,"insecurity.properties"); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map outConfig=new HashMap(); outConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.ENCRYPT); outConfig.put(ConfigurationConstants.ENCRYPTION_USER,"myalias"); outConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); outConfig.put(ConfigurationConstants.ENC_KEY_TRANSPORT,"http://www.w3.org/2001/04/xmlenc#rsa-1_5"); outConfig.put(ConfigurationConstants.ENC_SYM_ALGO,"http://www.w3.org/2001/04/xmlenc#tripledes-cbc"); outConfig.put(ConfigurationConstants.ENC_SYM_ALGO,WSSConstants.NS_XENC_AES128); outConfig.put(ConfigurationConstants.ENC_PROP_FILE,"outsecurity.properties"); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(outConfig); client.getOutInterceptors().add(ohandler); try { echo.echo("test"); fail("Failure expected as RSA v1.5 is not allowed by default"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { } inProperties.put(WSHandlerConstants.ALLOW_RSA15_KEY_TRANSPORT_ALGORITHM,"true"); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSignatureTimestampConfig() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.TIMESTAMP); inProperties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE,"insecurity.properties"); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map outConfig=new HashMap(); outConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.TIMESTAMP + " " + ConfigurationConstants.SIGNATURE); outConfig.put(ConfigurationConstants.SIGNATURE_PARTS,"{Element}{" + WSSConstants.NS_WSU10 + "}Timestamp;"+ "{Element}{"+ WSSConstants.NS_SOAP11+ "}Body"); outConfig.put(ConfigurationConstants.SIGNATURE_USER,"myalias"); outConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); outConfig.put(ConfigurationConstants.SIG_PROP_FILE,"outsecurity.properties"); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(outConfig); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSignatureConfirmationConfig() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE); inProperties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE,"insecurity.properties"); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Map outProperties=new HashMap(); outProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE); outProperties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); outProperties.put(WSHandlerConstants.SIG_PROP_FILE,"outsecurity.properties"); outProperties.put(WSHandlerConstants.ENABLE_SIGNATURE_CONFIRMATION,"true"); outProperties.put(WSHandlerConstants.USER,"myalias"); WSS4JOutInterceptor domOhandler=new WSS4JOutInterceptor(outProperties); service.getOutInterceptors().add(domOhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map clientOutConfig=new HashMap(); clientOutConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.SIGNATURE); clientOutConfig.put(ConfigurationConstants.SIGNATURE_USER,"myalias"); clientOutConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); clientOutConfig.put(ConfigurationConstants.SIG_PROP_FILE,"outsecurity.properties"); WSS4JStaxOutInterceptor clientOhandler=new WSS4JStaxOutInterceptor(clientOutConfig); client.getOutInterceptors().add(clientOhandler); Map clientInConfig=new HashMap(); clientInConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); clientInConfig.put(ConfigurationConstants.ENABLE_SIGNATURE_CONFIRMATION,"true"); clientInConfig.put(ConfigurationConstants.SIG_VER_PROP_FILE,"insecurity.properties"); WSS4JStaxInInterceptor clientInHandler=new WSS4JStaxInInterceptor(clientInConfig); client.getInInterceptors().add(clientInHandler); assertEquals("test",echo.echo("test")); }

UtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testUsernameTokenDigest() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.USERNAME_TOKEN); inProperties.put(WSHandlerConstants.PASSWORD_TYPE,WSConstants.PW_DIGEST); inProperties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.USERNAMETOKEN); properties.setActions(actions); properties.setUsernameTokenPasswordType(WSSConstants.UsernameTokenPasswordType.PASSWORD_DIGEST); properties.setTokenUser("username"); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); service.getInInterceptors().remove(inInterceptor); inProperties.put(WSHandlerConstants.PASSWORD_TYPE,WSConstants.PW_TEXT); inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); service.put(SecurityConstants.RETURN_SECURITY_ERROR,true); try { echo.echo("test"); fail("Failure expected on the wrong password type"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { String error="The security token could not be authenticated or authorized"; assertTrue(ex.getMessage().contains(error)); } }

EqualityVerifier 
@Test public void testSignatureTimestamp() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.TIMESTAMP); inProperties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE,"insecurity.properties"); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.TIMESTAMP); actions.add(WSSConstants.SIGNATURE); properties.setActions(actions); properties.addSignaturePart(new SecurePart(new QName(WSSConstants.NS_WSU10,"Timestamp"),SecurePart.Modifier.Element)); properties.addSignaturePart(new SecurePart(new QName(WSSConstants.NS_SOAP11,"Body"),SecurePart.Modifier.Element)); properties.setSignatureUser("myalias"); Properties cryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setSignatureCryptoProperties(cryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSignature() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE); inProperties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE,"insecurity.properties"); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.SIGNATURE); properties.setActions(actions); properties.setSignatureUser("myalias"); Properties cryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setSignatureCryptoProperties(cryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testEncryptSignature() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.ENCRYPT); inProperties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE,"insecurity.properties"); inProperties.put(WSHandlerConstants.DEC_PROP_FILE,"insecurity.properties"); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.ENCRYPT); actions.add(WSSConstants.SIGNATURE); properties.setActions(actions); properties.setEncryptionUser("myalias"); properties.setSignatureUser("myalias"); properties.setEncryptionSymAlgorithm(WSSConstants.NS_XENC_AES128); Properties cryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setEncryptionCryptoProperties(cryptoProperties); properties.setSignatureCryptoProperties(cryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSignaturePKI() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE); inProperties.put(WSHandlerConstants.PW_CALLBACK_REF,new KeystorePasswordCallback()); inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE,"cxfca.properties"); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.SIGNATURE); properties.setActions(actions); properties.setSignatureUser("alice"); Properties cryptoProperties=CryptoFactory.getProperties("alice.properties",this.getClass().getClassLoader()); properties.setSignatureCryptoProperties(cryptoProperties); properties.setCallbackHandler(new KeystorePasswordCallback()); properties.setUseSingleCert(true); properties.setSignatureKeyIdentifier(WSSecurityTokenConstants.KEYIDENTIFIER_SECURITY_TOKEN_DIRECT_REFERENCE); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testEncryptUsernameToken() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.USERNAME_TOKEN + " " + WSHandlerConstants.ENCRYPT); inProperties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); inProperties.put(WSHandlerConstants.DEC_PROP_FILE,"insecurity.properties"); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.USERNAMETOKEN); actions.add(WSSConstants.ENCRYPT); properties.setActions(actions); properties.addEncryptionPart(new SecurePart(new QName(WSSConstants.NS_WSSE10,"UsernameToken"),SecurePart.Modifier.Element)); properties.setEncryptionUser("myalias"); properties.setTokenUser("username"); properties.setEncryptionSymAlgorithm(WSSConstants.NS_XENC_AES128); Properties cryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setEncryptionCryptoProperties(cryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

UtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testTimestampConfig() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.TIMESTAMP); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map outConfig=new HashMap(); outConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.TIMESTAMP); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(outConfig); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); service.getInInterceptors().remove(inInterceptor); inProperties.put(WSHandlerConstants.ACTION,""); inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); service.put(SecurityConstants.RETURN_SECURITY_ERROR,true); try { echo.echo("test"); fail("Failure expected on no Timestamp"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { String error="An error was discovered"; assertTrue(ex.getMessage().contains(error)); } }

UtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testUsernameTokenDigestConfig() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.USERNAME_TOKEN); inProperties.put(WSHandlerConstants.PASSWORD_TYPE,WSConstants.PW_DIGEST); inProperties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map outConfig=new HashMap(); outConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.USERNAME_TOKEN); outConfig.put(ConfigurationConstants.PASSWORD_TYPE,"PasswordDigest"); outConfig.put(ConfigurationConstants.USER,"username"); outConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(outConfig); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); service.getInInterceptors().remove(inInterceptor); inProperties.put(WSHandlerConstants.PASSWORD_TYPE,WSConstants.PW_TEXT); inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); service.put(SecurityConstants.RETURN_SECURITY_ERROR,true); try { echo.echo("test"); fail("Failure expected on the wrong password type"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { String error="The security token could not be authenticated or authorized"; assertTrue(ex.getMessage().contains(error)); } }

UtilityVerifier BooleanVerifier EqualityVerifier HybridVerifier 
@Test public void testTimestamp() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.TIMESTAMP); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.TIMESTAMP); properties.setActions(actions); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); service.getInInterceptors().remove(inInterceptor); inProperties.put(WSHandlerConstants.ACTION,""); inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); service.put(SecurityConstants.RETURN_SECURITY_ERROR,true); try { echo.echo("test"); fail("Failure expected on no Timestamp"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { String error="An error was discovered"; assertTrue(ex.getMessage().contains(error)); } }

Class: org.apache.cxf.ws.security.wss4j.StaxToDOMSignatureIdentifierTest

EqualityVerifier 
@Test public void testSignatureThumbprint() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE); inProperties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE,"insecurity.properties"); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.SIGNATURE); properties.setActions(actions); properties.setSignatureKeyIdentifier(WSSecurityTokenConstants.KEYIDENTIFIER_THUMBPRINT_IDENTIFIER); properties.setSignatureUser("myalias"); Properties cryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setSignatureCryptoProperties(cryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSignatureX509() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE); inProperties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE,"insecurity.properties"); inProperties.put(WSHandlerConstants.IS_BSP_COMPLIANT,"false"); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.SIGNATURE); properties.setActions(actions); properties.setSignatureKeyIdentifier(WSSecurityTokenConstants.KeyIdentifier_X509KeyIdentifier); properties.setSignatureUser("myalias"); Properties cryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setSignatureCryptoProperties(cryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSignatureKeyValue() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE); inProperties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE,"insecurity.properties"); inProperties.put(WSHandlerConstants.IS_BSP_COMPLIANT,"false"); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.SIGNATURE); properties.setActions(actions); properties.setSignatureKeyIdentifier(WSSecurityTokenConstants.KeyIdentifier_KeyValue); properties.setSignatureUser("myalias"); Properties cryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setSignatureCryptoProperties(cryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSignatureIssuerSerial() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE); inProperties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE,"insecurity.properties"); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.SIGNATURE); properties.setActions(actions); properties.setSignatureKeyIdentifier(WSSecurityTokenConstants.KeyIdentifier_IssuerSerial); properties.setSignatureUser("myalias"); Properties cryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setSignatureCryptoProperties(cryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSignatureDirectReference() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE); inProperties.put(WSHandlerConstants.PW_CALLBACK_REF,new TestPwdCallback()); inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE,"insecurity.properties"); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.SIGNATURE); properties.setActions(actions); properties.setSignatureKeyIdentifier(WSSecurityTokenConstants.KEYIDENTIFIER_SECURITY_TOKEN_DIRECT_REFERENCE); properties.setSignatureUser("myalias"); Properties cryptoProperties=CryptoFactory.getProperties("outsecurity.properties",this.getClass().getClassLoader()); properties.setSignatureCryptoProperties(cryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

Class: org.apache.cxf.ws.security.wss4j.UserNameTokenAuthorizationTest

EqualityVerifier 
@Test public void testEncryptedDigestPasswordAuthorized() throws Exception { setUpService("developers",true,true); String actions=WSHandlerConstants.USERNAME_TOKEN + " " + WSHandlerConstants.ENCRYPT; wsIn.setProperty(WSHandlerConstants.ACTION,actions); wsOut.setProperty(WSHandlerConstants.ACTION,actions); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testClearPasswordAuthorized() throws Exception { setUpService("developers",false,false); String actions=WSHandlerConstants.USERNAME_TOKEN; wsIn.setProperty(WSHandlerConstants.ACTION,actions); wsOut.setProperty(WSHandlerConstants.ACTION,actions); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testDigestPasswordAuthorized() throws Exception { setUpService("developers",true,false); String actions=WSHandlerConstants.ENCRYPT + " " + WSHandlerConstants.SIGNATURE+ " "+ WSHandlerConstants.TIMESTAMP+ " "+ WSHandlerConstants.USERNAME_TOKEN; wsIn.setProperty(WSHandlerConstants.ACTION,actions); wsOut.setProperty(WSHandlerConstants.ACTION,actions); assertEquals("test",echo.echo("test")); }

UtilityVerifier EqualityVerifier HybridVerifier 
@Test public void testDigestPasswordUnauthorized() throws Exception { setUpService("managers",true,false); String actions=WSHandlerConstants.ENCRYPT + " " + WSHandlerConstants.SIGNATURE+ " "+ WSHandlerConstants.TIMESTAMP+ " "+ WSHandlerConstants.USERNAME_TOKEN; wsIn.setProperty(WSHandlerConstants.ACTION,actions); wsOut.setProperty(WSHandlerConstants.ACTION,actions); try { echo.echo("test"); fail("Exception expected"); } catch ( Exception ex) { assertEquals("Unauthorized",ex.getMessage()); } }

EqualityVerifier 
@Test public void testEncyptedClearPasswordAuthorized() throws Exception { setUpService("developers",false,true); String actions=WSHandlerConstants.USERNAME_TOKEN + " " + WSHandlerConstants.ENCRYPT; wsIn.setProperty(WSHandlerConstants.ACTION,actions); wsOut.setProperty(WSHandlerConstants.ACTION,actions); assertEquals("test",echo.echo("test")); }

Class: org.apache.cxf.ws.security.wss4j.WSS4JInOutTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testPKIPath() throws Exception { Map outProperties=new HashMap(); outProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE); outProperties.put(WSHandlerConstants.USER,"alice"); outProperties.put(WSHandlerConstants.SIG_PROP_FILE,"alice.properties"); outProperties.put(WSHandlerConstants.PW_CALLBACK_CLASS,KeystorePasswordCallback.class.getName()); outProperties.put(WSHandlerConstants.SIG_KEY_ID,"DirectReference"); outProperties.put(WSHandlerConstants.USE_SINGLE_CERTIFICATE,"false"); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE); inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE,"cxfca.properties"); List xpaths=new ArrayList(); xpaths.add("//wsse:Security"); xpaths.add("//wsse:Security/ds:Signature"); List handlerResults=getResults(makeInvocation(outProperties,xpaths,inProperties)); WSSecurityEngineResult actionResult=handlerResults.get(0).getActionResults().get(WSConstants.SIGN).get(0); X509Certificate[] certificates=(X509Certificate[])actionResult.get(WSSecurityEngineResult.TAG_X509_CERTIFICATES); assertNotNull(certificates); assertEquals(certificates.length,2); }

APIUtilityVerifier IdentityVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testEncryption() throws Exception { Map outProperties=new HashMap(); outProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.ENCRYPT); outProperties.put(WSHandlerConstants.ENC_PROP_FILE,"outsecurity.properties"); outProperties.put(WSHandlerConstants.USER,"myalias"); outProperties.put("password","myAliasPassword"); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.ENCRYPT); inProperties.put(WSHandlerConstants.DEC_PROP_FILE,"insecurity.properties"); inProperties.put(WSHandlerConstants.PW_CALLBACK_CLASS,"org.apache.cxf.ws.security.wss4j.TestPwdCallback"); List xpaths=new ArrayList(); xpaths.add("//wsse:Security"); xpaths.add("//s:Body/xenc:EncryptedData"); List handlerResults=getResults(makeInvocation(outProperties,xpaths,inProperties)); assertNotNull(handlerResults); assertSame(handlerResults.size(),1); final java.util.List protectionResults=handlerResults.get(0).getResults(); assertNotNull(protectionResults); assertSame(protectionResults.size(),1); final java.util.Map result=protectionResults.get(0); final java.util.List protectedElements=CastUtils.cast((List)result.get(WSSecurityEngineResult.TAG_DATA_REF_URIS)); assertNotNull(protectedElements); assertSame(protectedElements.size(),1); assertEquals(protectedElements.get(0).getName(),new javax.xml.namespace.QName("http://schemas.xmlsoap.org/soap/envelope/","Body")); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testCustomProcessorObject() throws Exception { Document doc=readDocument("wsse-request-clean.xml"); WSS4JOutInterceptor ohandler=new WSS4JOutInterceptor(); PhaseInterceptor handler=ohandler.createEndingInterceptor(); SoapMessage msg=new SoapMessage(new MessageImpl()); Exchange ex=new ExchangeImpl(); ex.setInMessage(msg); SOAPMessage saajMsg=MessageFactory.newInstance().createMessage(); SOAPPart part=saajMsg.getSOAPPart(); part.setContent(new DOMSource(doc)); saajMsg.saveChanges(); msg.setContent(SOAPMessage.class,saajMsg); msg.put(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE); msg.put(WSHandlerConstants.SIG_PROP_FILE,"outsecurity.properties"); msg.put(WSHandlerConstants.USER,"myalias"); msg.put("password","myAliasPassword"); handler.handleMessage(msg); doc=part; assertValid("//wsse:Security",doc); assertValid("//wsse:Security/ds:Signature",doc); byte[] docbytes=getMessageBytes(doc); XMLStreamReader reader=StaxUtils.createXMLStreamReader(new ByteArrayInputStream(docbytes)); DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance(); dbf.setValidating(false); dbf.setIgnoringComments(false); dbf.setIgnoringElementContentWhitespace(true); dbf.setNamespaceAware(true); DocumentBuilder db=dbf.newDocumentBuilder(); db.setEntityResolver(new NullResolver()); doc=StaxUtils.read(db,reader,false); final Map properties=new HashMap(); final Map customMap=new HashMap(); customMap.put(new QName(WSConstants.SIG_NS,WSConstants.SIG_LN),CustomProcessor.class); properties.put(WSS4JInInterceptor.PROCESSOR_MAP,customMap); WSS4JInInterceptor inHandler=new WSS4JInInterceptor(properties); SoapMessage inmsg=new SoapMessage(new MessageImpl()); ex.setInMessage(inmsg); inmsg.setContent(SOAPMessage.class,saajMsg); inHandler.setProperty(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE); inHandler.handleMessage(inmsg); List results=getResults(inmsg); assertTrue(results != null && results.size() == 1); List signatureResults=results.get(0).getActionResults().get(WSConstants.SIGN); assertTrue(signatureResults.size() == 1); Object obj=signatureResults.get(0).get("foo"); assertNotNull(obj); assertEquals(obj.getClass().getName(),CustomProcessor.class.getName()); }

Class: org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptorTest

EqualityVerifier 
@Test public void testOverrideCustomAction() throws Exception { SOAPMessage saaj=readSAAJDocument("wsse-request-clean.xml"); WSS4JOutInterceptor ohandler=new WSS4JOutInterceptor(); PhaseInterceptor handler=ohandler.createEndingInterceptor(); SoapMessage msg=new SoapMessage(new MessageImpl()); Exchange ex=new ExchangeImpl(); ex.setInMessage(msg); msg.setContent(SOAPMessage.class,saaj); CountingUsernameTokenAction action=new CountingUsernameTokenAction(); Map customActions=new HashMap(1); customActions.put(WSConstants.UT,action); msg.put(WSHandlerConstants.ACTION,WSHandlerConstants.USERNAME_TOKEN); msg.put(WSHandlerConstants.SIG_PROP_FILE,"outsecurity.properties"); msg.put(WSHandlerConstants.USER,"username"); msg.put("password","myAliasPassword"); msg.put(WSHandlerConstants.PASSWORD_TYPE,WSConstants.PW_TEXT); msg.put(WSS4JOutInterceptor.WSS4J_ACTION_MAP,customActions); handler.handleMessage(msg); SOAPPart doc=saaj.getSOAPPart(); assertValid("//wsse:Security",doc); assertValid("//wsse:Security/wsse:UsernameToken",doc); assertValid("//wsse:Security/wsse:UsernameToken/wsse:Username[text()='username']",doc); assertValid("//wsse:Security/wsse:UsernameToken/wsse:Password[text()='myAliasPassword']",doc); assertEquals(1,action.getExecutions()); try { customActions.put(WSConstants.UT,new Object()); handler.handleMessage(msg); } catch ( SoapFault e) { assertEquals("An invalid action configuration was defined.",e.getMessage()); } try { customActions.put(new Object(),CountingUsernameTokenAction.class); handler.handleMessage(msg); } catch ( SoapFault e) { assertEquals("An invalid action configuration was defined.",e.getMessage()); } }

EqualityVerifier 
@Test public void testAddCustomAction() throws Exception { SOAPMessage saaj=readSAAJDocument("wsse-request-clean.xml"); WSS4JOutInterceptor ohandler=new WSS4JOutInterceptor(); PhaseInterceptor handler=ohandler.createEndingInterceptor(); SoapMessage msg=new SoapMessage(new MessageImpl()); Exchange ex=new ExchangeImpl(); ex.setInMessage(msg); msg.setContent(SOAPMessage.class,saaj); CountingUsernameTokenAction action=new CountingUsernameTokenAction(); Map customActions=new HashMap(1); customActions.put(12345,action); msg.put(WSHandlerConstants.ACTION,"12345"); msg.put(WSHandlerConstants.SIG_PROP_FILE,"outsecurity.properties"); msg.put(WSHandlerConstants.USER,"username"); msg.put("password","myAliasPassword"); msg.put(WSHandlerConstants.PASSWORD_TYPE,WSConstants.PW_TEXT); msg.put(WSS4JOutInterceptor.WSS4J_ACTION_MAP,customActions); handler.handleMessage(msg); SOAPPart doc=saaj.getSOAPPart(); assertValid("//wsse:Security",doc); assertValid("//wsse:Security/wsse:UsernameToken",doc); assertValid("//wsse:Security/wsse:UsernameToken/wsse:Username[text()='username']",doc); assertValid("//wsse:Security/wsse:UsernameToken/wsse:Password[text()='myAliasPassword']",doc); assertEquals(1,action.getExecutions()); }

Class: org.apache.cxf.ws.security.wss4j.saml.DOMToStaxSamlTest

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testSaml2TokenHOK() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setSignatureVerificationCryptoProperties(cryptoProperties); CustomStaxSamlValidator validator=new CustomStaxSamlValidator(); inProperties.addValidator(WSConstants.SAML_TOKEN,validator); inProperties.addValidator(WSConstants.SAML2_TOKEN,validator); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map properties=new HashMap(); properties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SAML_TOKEN_SIGNED); SAML2CallbackHandler callbackHandler=new SAML2CallbackHandler(); callbackHandler.setConfirmationMethod(SAML2Constants.CONF_HOLDER_KEY); callbackHandler.setSignAssertion(true); properties.put(WSHandlerConstants.SAML_CALLBACK_REF,callbackHandler); properties.put(WSHandlerConstants.SIG_KEY_ID,"DirectReference"); properties.put(WSHandlerConstants.USER,"alice"); properties.put(WSHandlerConstants.PW_CALLBACK_REF,new PasswordCallbackHandler()); properties.put(WSHandlerConstants.SIG_PROP_FILE,"alice.properties"); WSS4JOutInterceptor ohandler=new WSS4JOutInterceptor(properties); client.getOutInterceptors().add(ohandler); try { echo.echo("test"); fail("Failure expected on receiving sender vouches instead of HOK"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { } validator.setRequireSenderVouches(false); try { echo.echo("test"); fail("Failure expected on receiving a SAML 1.1 Token instead of SAML 2.0"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { } validator.setRequireSAML1Assertion(false); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSaml1SignedSenderVouches() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setSignatureVerificationCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map properties=new HashMap(); properties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SAML_TOKEN_SIGNED); properties.put(WSHandlerConstants.SAML_CALLBACK_CLASS,"org.apache.cxf.ws.security.wss4j.saml.SAML1CallbackHandler"); properties.put(WSHandlerConstants.SIG_KEY_ID,"DirectReference"); properties.put(WSHandlerConstants.USER,"alice"); properties.put(WSHandlerConstants.PW_CALLBACK_REF,new PasswordCallbackHandler()); properties.put(WSHandlerConstants.SIG_PROP_FILE,"alice.properties"); WSS4JOutInterceptor ohandler=new WSS4JOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSaml2SignedSenderVouches() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setSignatureVerificationCryptoProperties(cryptoProperties); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map properties=new HashMap(); properties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SAML_TOKEN_SIGNED); properties.put(WSHandlerConstants.SAML_CALLBACK_CLASS,"org.apache.cxf.ws.security.wss4j.saml.SAML2CallbackHandler"); properties.put(WSHandlerConstants.SIG_KEY_ID,"DirectReference"); properties.put(WSHandlerConstants.USER,"alice"); properties.put(WSHandlerConstants.PW_CALLBACK_REF,new PasswordCallbackHandler()); properties.put(WSHandlerConstants.SIG_PROP_FILE,"alice.properties"); WSS4JOutInterceptor ohandler=new WSS4JOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSaml1() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setValidateSamlSubjectConfirmation(false); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map properties=new HashMap(); properties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SAML_TOKEN_UNSIGNED); properties.put(WSHandlerConstants.SAML_CALLBACK_REF,new SAML1CallbackHandler()); WSS4JOutInterceptor ohandler=new WSS4JOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testSaml1TokenHOK() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); Properties cryptoProperties=CryptoFactory.getProperties("insecurity.properties",this.getClass().getClassLoader()); inProperties.setSignatureVerificationCryptoProperties(cryptoProperties); CustomStaxSamlValidator validator=new CustomStaxSamlValidator(); inProperties.addValidator(WSConstants.SAML_TOKEN,validator); inProperties.addValidator(WSConstants.SAML2_TOKEN,validator); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map properties=new HashMap(); properties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SAML_TOKEN_SIGNED); SAML1CallbackHandler callbackHandler=new SAML1CallbackHandler(); callbackHandler.setConfirmationMethod(SAML1Constants.CONF_HOLDER_KEY); callbackHandler.setSignAssertion(true); properties.put(WSHandlerConstants.SAML_CALLBACK_REF,callbackHandler); properties.put(WSHandlerConstants.SIG_KEY_ID,"DirectReference"); properties.put(WSHandlerConstants.USER,"alice"); properties.put(WSHandlerConstants.PW_CALLBACK_REF,new PasswordCallbackHandler()); properties.put(WSHandlerConstants.SIG_PROP_FILE,"alice.properties"); WSS4JOutInterceptor ohandler=new WSS4JOutInterceptor(properties); client.getOutInterceptors().add(ohandler); try { echo.echo("test"); fail("Failure expected on receiving sender vouches instead of HOK"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { } validator.setRequireSenderVouches(false); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSaml2() throws Exception { Service service=createService(); WSSSecurityProperties inProperties=new WSSSecurityProperties(); inProperties.setValidateSamlSubjectConfirmation(false); WSS4JStaxInInterceptor inhandler=new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map properties=new HashMap(); properties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SAML_TOKEN_UNSIGNED); properties.put(WSHandlerConstants.SAML_CALLBACK_REF,new SAML2CallbackHandler()); WSS4JOutInterceptor ohandler=new WSS4JOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

Class: org.apache.cxf.ws.security.wss4j.saml.StaxToDOMSamlTest

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testSaml2TokenHOKConfig() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SAML_TOKEN_SIGNED + " " + WSHandlerConstants.SIGNATURE); inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE,"insecurity.properties"); final Map customMap=new HashMap(); CustomSamlValidator validator=new CustomSamlValidator(); customMap.put(WSConstants.SAML_TOKEN,validator); customMap.put(WSConstants.SAML2_TOKEN,validator); inProperties.put(WSS4JInInterceptor.VALIDATOR_MAP,customMap); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map outConfig=new HashMap(); outConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.SAML_TOKEN_SIGNED); SAML2CallbackHandler callbackHandler=new SAML2CallbackHandler(); callbackHandler.setSignAssertion(true); callbackHandler.setConfirmationMethod(SAML2Constants.CONF_HOLDER_KEY); outConfig.put(ConfigurationConstants.SAML_CALLBACK_REF,callbackHandler); outConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new PasswordCallbackHandler()); outConfig.put(ConfigurationConstants.SIGNATURE_USER,"alice"); outConfig.put(ConfigurationConstants.SIG_PROP_FILE,"alice.properties"); outConfig.put(ConfigurationConstants.SIG_KEY_ID,"DirectReference"); outConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new PasswordCallbackHandler()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(outConfig); client.getOutInterceptors().add(ohandler); try { echo.echo("test"); fail("Failure expected on receiving sender vouches instead of HOK"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { } validator.setRequireSenderVouches(false); try { echo.echo("test"); fail("Failure expected on receiving a SAML 1.1 Token instead of SAML 2.0"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { } validator.setRequireSAML1Assertion(false); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSaml1Config() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SAML_TOKEN_UNSIGNED); final Map customMap=new HashMap(); CustomSamlValidator validator=new CustomSamlValidator(); customMap.put(WSConstants.SAML_TOKEN,validator); customMap.put(WSConstants.SAML2_TOKEN,validator); inProperties.put(WSS4JInInterceptor.VALIDATOR_MAP,customMap); inProperties.put(SecurityConstants.VALIDATE_SAML_SUBJECT_CONFIRMATION,"false"); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); service.put(SecurityConstants.VALIDATE_SAML_SUBJECT_CONFIRMATION,"false"); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map outConfig=new HashMap(); outConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.SAML_TOKEN_UNSIGNED); outConfig.put(ConfigurationConstants.SAML_CALLBACK_REF,new SAML1CallbackHandler()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(outConfig); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSaml2Config() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SAML_TOKEN_UNSIGNED); final Map customMap=new HashMap(); CustomSamlValidator validator=new CustomSamlValidator(); validator.setRequireSAML1Assertion(false); customMap.put(WSConstants.SAML_TOKEN,validator); customMap.put(WSConstants.SAML2_TOKEN,validator); inProperties.put(WSS4JInInterceptor.VALIDATOR_MAP,customMap); inProperties.put(SecurityConstants.VALIDATE_SAML_SUBJECT_CONFIRMATION,"false"); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); service.put(SecurityConstants.VALIDATE_SAML_SUBJECT_CONFIRMATION,"false"); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map outConfig=new HashMap(); outConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.SAML_TOKEN_UNSIGNED); outConfig.put(ConfigurationConstants.SAML_CALLBACK_REF,new SAML2CallbackHandler()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(outConfig); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testSaml1TokenHOKConfig() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SAML_TOKEN_SIGNED + " " + WSHandlerConstants.SIGNATURE); inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE,"insecurity.properties"); final Map customMap=new HashMap(); CustomSamlValidator validator=new CustomSamlValidator(); customMap.put(WSConstants.SAML_TOKEN,validator); customMap.put(WSConstants.SAML2_TOKEN,validator); inProperties.put(WSS4JInInterceptor.VALIDATOR_MAP,customMap); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map outConfig=new HashMap(); outConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.SAML_TOKEN_SIGNED); SAML1CallbackHandler callbackHandler=new SAML1CallbackHandler(); callbackHandler.setSignAssertion(true); callbackHandler.setConfirmationMethod(SAML1Constants.CONF_HOLDER_KEY); outConfig.put(ConfigurationConstants.SAML_CALLBACK_REF,callbackHandler); outConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new PasswordCallbackHandler()); outConfig.put(ConfigurationConstants.SIGNATURE_USER,"alice"); outConfig.put(ConfigurationConstants.SIG_PROP_FILE,"alice.properties"); outConfig.put(ConfigurationConstants.SIG_KEY_ID,"DirectReference"); outConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new PasswordCallbackHandler()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(outConfig); client.getOutInterceptors().add(ohandler); try { echo.echo("test"); fail("Failure expected on receiving sender vouches instead of HOK"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { } validator.setRequireSenderVouches(false); assertEquals("test",echo.echo("test")); }

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testSaml2TokenHOK() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SAML_TOKEN_SIGNED + " " + WSHandlerConstants.SIGNATURE); inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE,"insecurity.properties"); final Map customMap=new HashMap(); CustomSamlValidator validator=new CustomSamlValidator(); customMap.put(WSConstants.SAML_TOKEN,validator); customMap.put(WSConstants.SAML2_TOKEN,validator); inProperties.put(WSS4JInInterceptor.VALIDATOR_MAP,customMap); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.SAML_TOKEN_SIGNED); properties.setActions(actions); SAML2CallbackHandler callbackHandler=new SAML2CallbackHandler(); callbackHandler.setSignAssertion(true); callbackHandler.setConfirmationMethod(SAML2Constants.CONF_HOLDER_KEY); properties.setSamlCallbackHandler(callbackHandler); properties.setCallbackHandler(new PasswordCallbackHandler()); properties.setSignatureUser("alice"); Properties cryptoProperties=CryptoFactory.getProperties("alice.properties",this.getClass().getClassLoader()); properties.setSignatureCryptoProperties(cryptoProperties); properties.setSignatureKeyIdentifier(WSSecurityTokenConstants.KEYIDENTIFIER_SECURITY_TOKEN_DIRECT_REFERENCE); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); try { echo.echo("test"); fail("Failure expected on receiving sender vouches instead of HOK"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { } validator.setRequireSenderVouches(false); try { echo.echo("test"); fail("Failure expected on receiving a SAML 1.1 Token instead of SAML 2.0"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { } validator.setRequireSAML1Assertion(false); assertEquals("test",echo.echo("test")); }

UtilityVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testSaml1TokenHOK() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SAML_TOKEN_SIGNED + " " + WSHandlerConstants.SIGNATURE); inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE,"insecurity.properties"); final Map customMap=new HashMap(); CustomSamlValidator validator=new CustomSamlValidator(); customMap.put(WSConstants.SAML_TOKEN,validator); customMap.put(WSConstants.SAML2_TOKEN,validator); inProperties.put(WSS4JInInterceptor.VALIDATOR_MAP,customMap); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.SAML_TOKEN_SIGNED); properties.setActions(actions); SAML1CallbackHandler callbackHandler=new SAML1CallbackHandler(); callbackHandler.setSignAssertion(true); callbackHandler.setConfirmationMethod(SAML1Constants.CONF_HOLDER_KEY); properties.setSamlCallbackHandler(callbackHandler); properties.setSignatureUser("alice"); Properties cryptoProperties=CryptoFactory.getProperties("alice.properties",this.getClass().getClassLoader()); properties.setSignatureCryptoProperties(cryptoProperties); properties.setSignatureKeyIdentifier(WSSecurityTokenConstants.KEYIDENTIFIER_SECURITY_TOKEN_DIRECT_REFERENCE); properties.setCallbackHandler(new PasswordCallbackHandler()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); try { echo.echo("test"); fail("Failure expected on receiving sender vouches instead of HOK"); } catch ( javax.xml.ws.soap.SOAPFaultException ex) { } validator.setRequireSenderVouches(false); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSaml2SignedSenderVouches() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SAML_TOKEN_UNSIGNED + " " + WSHandlerConstants.SIGNATURE); inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE,"insecurity.properties"); final Map customMap=new HashMap(); CustomSamlValidator validator=new CustomSamlValidator(); validator.setRequireSAML1Assertion(false); customMap.put(WSConstants.SAML_TOKEN,validator); customMap.put(WSConstants.SAML2_TOKEN,validator); inProperties.put(WSS4JInInterceptor.VALIDATOR_MAP,customMap); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.SAML_TOKEN_SIGNED); properties.setActions(actions); properties.setSamlCallbackHandler(new SAML2CallbackHandler()); properties.setCallbackHandler(new PasswordCallbackHandler()); properties.setSignatureKeyIdentifier(WSSecurityTokenConstants.KEYIDENTIFIER_SECURITY_TOKEN_DIRECT_REFERENCE); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSaml2SignedSenderVouchesConfig() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SAML_TOKEN_UNSIGNED + " " + WSHandlerConstants.SIGNATURE); inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE,"insecurity.properties"); final Map customMap=new HashMap(); CustomSamlValidator validator=new CustomSamlValidator(); validator.setRequireSAML1Assertion(false); customMap.put(WSConstants.SAML_TOKEN,validator); customMap.put(WSConstants.SAML2_TOKEN,validator); inProperties.put(WSS4JInInterceptor.VALIDATOR_MAP,customMap); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map outConfig=new HashMap(); outConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.SAML_TOKEN_SIGNED); outConfig.put(ConfigurationConstants.SAML_CALLBACK_REF,new SAML2CallbackHandler()); outConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new PasswordCallbackHandler()); outConfig.put(ConfigurationConstants.SIG_KEY_ID,"DirectReference"); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(outConfig); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSaml1SignedSenderVouches() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SAML_TOKEN_UNSIGNED + " " + WSHandlerConstants.SIGNATURE); inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE,"insecurity.properties"); final Map customMap=new HashMap(); CustomSamlValidator validator=new CustomSamlValidator(); customMap.put(WSConstants.SAML_TOKEN,validator); customMap.put(WSConstants.SAML2_TOKEN,validator); inProperties.put(WSS4JInInterceptor.VALIDATOR_MAP,customMap); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.SAML_TOKEN_SIGNED); properties.setActions(actions); properties.setSamlCallbackHandler(new SAML1CallbackHandler()); properties.setCallbackHandler(new PasswordCallbackHandler()); properties.setSignatureKeyIdentifier(WSSecurityTokenConstants.KEYIDENTIFIER_SECURITY_TOKEN_DIRECT_REFERENCE); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSaml1SignedSenderVouchesConfig() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SAML_TOKEN_UNSIGNED + " " + WSHandlerConstants.SIGNATURE); inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE,"insecurity.properties"); final Map customMap=new HashMap(); CustomSamlValidator validator=new CustomSamlValidator(); customMap.put(WSConstants.SAML_TOKEN,validator); customMap.put(WSConstants.SAML2_TOKEN,validator); inProperties.put(WSS4JInInterceptor.VALIDATOR_MAP,customMap); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); Map outConfig=new HashMap(); outConfig.put(ConfigurationConstants.ACTION,ConfigurationConstants.SAML_TOKEN_SIGNED); outConfig.put(ConfigurationConstants.SAML_CALLBACK_REF,new SAML1CallbackHandler()); outConfig.put(ConfigurationConstants.PW_CALLBACK_REF,new PasswordCallbackHandler()); outConfig.put(ConfigurationConstants.SIG_KEY_ID,"DirectReference"); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(outConfig); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSaml2() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SAML_TOKEN_UNSIGNED); final Map customMap=new HashMap(); CustomSamlValidator validator=new CustomSamlValidator(); validator.setRequireSAML1Assertion(false); customMap.put(WSConstants.SAML_TOKEN,validator); customMap.put(WSConstants.SAML2_TOKEN,validator); inProperties.put(WSS4JInInterceptor.VALIDATOR_MAP,customMap); inProperties.put(SecurityConstants.VALIDATE_SAML_SUBJECT_CONFIRMATION,"false"); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); service.put(SecurityConstants.VALIDATE_SAML_SUBJECT_CONFIRMATION,"false"); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.SAML_TOKEN_UNSIGNED); properties.setActions(actions); properties.setSamlCallbackHandler(new SAML2CallbackHandler()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

EqualityVerifier 
@Test public void testSaml1() throws Exception { Service service=createService(); Map inProperties=new HashMap(); inProperties.put(WSHandlerConstants.ACTION,WSHandlerConstants.SAML_TOKEN_UNSIGNED); final Map customMap=new HashMap(); CustomSamlValidator validator=new CustomSamlValidator(); customMap.put(WSConstants.SAML_TOKEN,validator); customMap.put(WSConstants.SAML2_TOKEN,validator); inProperties.put(WSS4JInInterceptor.VALIDATOR_MAP,customMap); inProperties.put(SecurityConstants.VALIDATE_SAML_SUBJECT_CONFIRMATION,"false"); WSS4JInInterceptor inInterceptor=new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); service.put(SecurityConstants.VALIDATE_SAML_SUBJECT_CONFIRMATION,"false"); Echo echo=createClientProxy(); Client client=ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); WSSSecurityProperties properties=new WSSSecurityProperties(); List actions=new ArrayList(); actions.add(WSSConstants.SAML_TOKEN_UNSIGNED); properties.setActions(actions); properties.setSamlCallbackHandler(new SAML1CallbackHandler()); WSS4JStaxOutInterceptor ohandler=new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test",echo.echo("test")); }

Class: org.apache.cxf.wsdl.interceptors.DocLiteralInInterceptorTest

InternalCallVerifier EqualityVerifier 
@Test public void testUnmarshalSourceData() throws Exception { XMLStreamReader reader=StaxUtils.createXMLStreamReader(getClass().getResourceAsStream("resources/multiPartDocLitBareReq.xml")); assertEquals(XMLStreamConstants.START_ELEMENT,reader.nextTag()); XMLStreamReader filteredReader=new PartialXMLStreamReader(reader,new QName("http://schemas.xmlsoap.org/soap/envelope/","Body")); StaxUtils.read(filteredReader); assertEquals(XMLStreamConstants.START_ELEMENT,reader.nextTag()); Message m=new MessageImpl(); Exchange exchange=new ExchangeImpl(); Service service=control.createMock(Service.class); exchange.put(Service.class,service); EasyMock.expect(service.getDataBinding()).andReturn(new SourceDataBinding()); EasyMock.expect(service.size()).andReturn(0).anyTimes(); EasyMock.expect(service.isEmpty()).andReturn(true).anyTimes(); Endpoint endpoint=control.createMock(Endpoint.class); exchange.put(Endpoint.class,endpoint); OperationInfo operationInfo=new OperationInfo(); operationInfo.setProperty("operation.is.synthetic",Boolean.TRUE); MessageInfo messageInfo=new MessageInfo(operationInfo,Type.INPUT,new QName("http://foo.com","bar")); messageInfo.addMessagePart(new MessagePartInfo(new QName("http://foo.com","partInfo1"),null)); messageInfo.addMessagePart(new MessagePartInfo(new QName("http://foo.com","partInfo2"),null)); messageInfo.addMessagePart(new MessagePartInfo(new QName("http://foo.com","partInfo3"),null)); messageInfo.addMessagePart(new MessagePartInfo(new QName("http://foo.com","partInfo4"),null)); for ( MessagePartInfo mpi : messageInfo.getMessageParts()) { mpi.setMessageContainer(messageInfo); } operationInfo.setInput("inputName",messageInfo); BindingOperationInfo boi=new BindingOperationInfo(null,operationInfo); exchange.put(BindingOperationInfo.class,boi); EndpointInfo endpointInfo=control.createMock(EndpointInfo.class); BindingInfo binding=control.createMock(BindingInfo.class); EasyMock.expect(endpoint.getEndpointInfo()).andReturn(endpointInfo).anyTimes(); EasyMock.expect(endpointInfo.getBinding()).andReturn(binding).anyTimes(); EasyMock.expect(binding.getProperties()).andReturn(new HashMap()).anyTimes(); EasyMock.expect(endpointInfo.getProperties()).andReturn(new HashMap()).anyTimes(); EasyMock.expect(endpoint.size()).andReturn(0).anyTimes(); EasyMock.expect(endpoint.isEmpty()).andReturn(true).anyTimes(); ServiceInfo serviceInfo=control.createMock(ServiceInfo.class); EasyMock.expect(endpointInfo.getService()).andReturn(serviceInfo).anyTimes(); EasyMock.expect(serviceInfo.getName()).andReturn(new QName("http://foo.com","service")).anyTimes(); InterfaceInfo interfaceInfo=control.createMock(InterfaceInfo.class); EasyMock.expect(serviceInfo.getInterface()).andReturn(interfaceInfo).anyTimes(); EasyMock.expect(interfaceInfo.getName()).andReturn(new QName("http://foo.com","interface")).anyTimes(); EasyMock.expect(endpointInfo.getName()).andReturn(new QName("http://foo.com","endpoint")).anyTimes(); EasyMock.expect(endpointInfo.getProperty("URI",URI.class)).andReturn(new URI("dummy")).anyTimes(); List operations=new ArrayList(); EasyMock.expect(interfaceInfo.getOperations()).andReturn(operations).anyTimes(); m.setExchange(exchange); m.put(Message.SCHEMA_VALIDATION_ENABLED,false); m.setContent(XMLStreamReader.class,reader); control.replay(); new DocLiteralInInterceptor().handleMessage(m); MessageContentsList params=(MessageContentsList)m.getContent(List.class); assertEquals(4,params.size()); assertEquals("StringDefaultInputElem",((DOMSource)params.get(0)).getNode().getFirstChild().getNodeName()); assertEquals("IntParamInElem",((DOMSource)params.get(1)).getNode().getFirstChild().getNodeName()); }

InternalCallVerifier EqualityVerifier 
@Test public void testUnmarshalSourceDataWrapped() throws Exception { XMLStreamReader reader=StaxUtils.createXMLStreamReader(getClass().getResourceAsStream("resources/docLitWrappedReq.xml")); assertEquals(XMLStreamConstants.START_ELEMENT,reader.nextTag()); XMLStreamReader filteredReader=new PartialXMLStreamReader(reader,new QName("http://schemas.xmlsoap.org/soap/envelope/","Body")); StaxUtils.read(filteredReader); assertEquals(XMLStreamConstants.START_ELEMENT,reader.nextTag()); Message m=new MessageImpl(); m.put(DocLiteralInInterceptor.KEEP_PARAMETERS_WRAPPER,true); Exchange exchange=new ExchangeImpl(); Service service=control.createMock(Service.class); exchange.put(Service.class,service); EasyMock.expect(service.getDataBinding()).andReturn(new SourceDataBinding()).anyTimes(); EasyMock.expect(service.size()).andReturn(0).anyTimes(); EasyMock.expect(service.isEmpty()).andReturn(true).anyTimes(); Endpoint endpoint=control.createMock(Endpoint.class); exchange.put(Endpoint.class,endpoint); OperationInfo operationInfo=new OperationInfo(); MessageInfo messageInfo=new MessageInfo(operationInfo,Type.INPUT,new QName(NS,"foo")); messageInfo.addMessagePart(new MessagePartInfo(new QName(NS,"personId"),null)); messageInfo.addMessagePart(new MessagePartInfo(new QName(NS,"ssn"),null)); messageInfo.getMessagePart(0).setConcreteName(new QName(NS,"personId")); messageInfo.getMessagePart(1).setConcreteName(new QName(NS,"ssn")); operationInfo.setInput("inputName",messageInfo); OperationInfo operationInfoWrapper=new OperationInfo(); MessageInfo messageInfoWrapper=new MessageInfo(operationInfo,Type.INPUT,new QName(NS,"foo")); messageInfoWrapper.addMessagePart(new MessagePartInfo(new QName(NS,"GetPerson"),null)); messageInfoWrapper.getMessagePart(0).setConcreteName(new QName(NS,"GetPerson")); operationInfoWrapper.setInput("inputName",messageInfoWrapper); operationInfoWrapper.setUnwrappedOperation(operationInfo); ServiceInfo serviceInfo=control.createMock(ServiceInfo.class); EasyMock.expect(serviceInfo.getName()).andReturn(new QName("http://foo.com","service")).anyTimes(); InterfaceInfo interfaceInfo=control.createMock(InterfaceInfo.class); EasyMock.expect(serviceInfo.getInterface()).andReturn(interfaceInfo).anyTimes(); EasyMock.expect(interfaceInfo.getName()).andReturn(new QName("http://foo.com","interface")).anyTimes(); BindingInfo bindingInfo=new BindingInfo(serviceInfo,""); BindingOperationInfo boi=new BindingOperationInfo(bindingInfo,operationInfoWrapper); exchange.put(BindingOperationInfo.class,boi); EndpointInfo endpointInfo=control.createMock(EndpointInfo.class); BindingInfo binding=control.createMock(BindingInfo.class); EasyMock.expect(endpoint.getEndpointInfo()).andReturn(endpointInfo).anyTimes(); EasyMock.expect(endpointInfo.getBinding()).andReturn(binding).anyTimes(); EasyMock.expect(binding.getProperties()).andReturn(new HashMap()).anyTimes(); EasyMock.expect(endpointInfo.getProperties()).andReturn(new HashMap()).anyTimes(); EasyMock.expect(endpoint.size()).andReturn(0).anyTimes(); EasyMock.expect(endpoint.isEmpty()).andReturn(true).anyTimes(); EasyMock.expect(endpointInfo.getService()).andReturn(serviceInfo).anyTimes(); EasyMock.expect(endpointInfo.getName()).andReturn(new QName("http://foo.com","endpoint")).anyTimes(); EasyMock.expect(endpointInfo.getProperty("URI",URI.class)).andReturn(new URI("dummy")).anyTimes(); List operations=new ArrayList(); EasyMock.expect(interfaceInfo.getOperations()).andReturn(operations).anyTimes(); m.setExchange(exchange); m.put(Message.SCHEMA_VALIDATION_ENABLED,false); m.setContent(XMLStreamReader.class,reader); control.replay(); new DocLiteralInInterceptor().handleMessage(m); MessageContentsList params=(MessageContentsList)m.getContent(List.class); assertEquals(1,params.size()); Map ns=new HashMap(); ns.put("ns",NS); XPathUtils xu=new XPathUtils(ns); assertEquals("hello",xu.getValueString("//ns:GetPerson/ns:personId",((DOMSource)params.get(0)).getNode().getFirstChild())); assertEquals("1234",xu.getValueString("//ns:GetPerson/ns:ssn",((DOMSource)params.get(0)).getNode().getFirstChild())); }

Class: org.apache.cxf.wsdl11.NSManagerTest

InternalCallVerifier EqualityVerifier 
@Test public void testGetPrefix(){ NSManager nsMan=new NSManager(); assertEquals("wsaw",nsMan.getPrefixFromNS(JAXWSAConstants.NS_WSAW)); assertEquals("soap",nsMan.getPrefixFromNS(WSDLConstants.NS_SOAP)); assertEquals("soap12",nsMan.getPrefixFromNS(WSDLConstants.NS_SOAP12)); }

Class: org.apache.cxf.wsdl11.ServiceWSDLBuilderTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSchemas() throws Exception { setupWSDL(WSDL_PATH); Types types=newDef.getTypes(); assertNotNull(types); Collection schemas=CastUtils.cast(types.getExtensibilityElements(),ExtensibilityElement.class); assertEquals(1,schemas.size()); XmlSchemaCollection schemaCollection=new XmlSchemaCollection(); Element schemaElem=((Schema)schemas.iterator().next()).getElement(); XmlSchema newSchema=schemaCollection.read(schemaElem); assertEquals("http://apache.org/hello_world_soap_http/types",newSchema.getTargetNamespace()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGreetMeOperation() throws Exception { setupWSDL(WSDL_PATH); PortType portType=newDef.getPortType(new QName(newDef.getTargetNamespace(),"Greeter")); Operation greetMe=portType.getOperation("greetMe","greetMeRequest","greetMeResponse"); assertNotNull(greetMe); assertEquals("greetMe",greetMe.getName()); Input input=greetMe.getInput(); assertNotNull(input); assertEquals("greetMeRequest",input.getName()); Message message=input.getMessage(); assertNotNull(message); assertEquals("greetMeRequest",message.getQName().getLocalPart()); assertEquals(newDef.getTargetNamespace(),message.getQName().getNamespaceURI()); assertEquals(1,message.getParts().size()); assertEquals("in",message.getPart("in").getName()); Output output=greetMe.getOutput(); assertNotNull(output); assertEquals("greetMeResponse",output.getName()); message=output.getMessage(); assertNotNull(message); assertEquals("greetMeResponse",message.getQName().getLocalPart()); assertEquals(newDef.getTargetNamespace(),message.getQName().getNamespaceURI()); assertEquals(1,message.getParts().size()); assertEquals("out",message.getPart("out").getName()); assertEquals(0,greetMe.getFaults().size()); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testXsdImportMultipleSchemas() throws Exception { setupWSDL(WSDL_XSD_IMPORT_PATH,true); Types types=newDef.getTypes(); assertNotNull(types); Collection schemas=CastUtils.cast(types.getExtensibilityElements(),ExtensibilityElement.class); assertEquals(1,schemas.size()); Schema schema=(Schema)schemas.iterator().next(); assertEquals(1,schema.getImports().values().size()); SchemaImport serviceTypesSchemaImport=getImport(schema.getImports(),"http://apache.org/hello_world_soap_http/servicetypes"); Schema serviceTypesSchema=serviceTypesSchemaImport.getReferencedSchema(); assertEquals(1,serviceTypesSchema.getImports().values().size()); SchemaImport typesSchemaImport=getImport(serviceTypesSchema.getImports(),"http://apache.org/hello_world_soap_http/types"); Schema typesSchema=typesSchemaImport.getReferencedSchema(); Document doc=typesSchema.getElement().getOwnerDocument(); ByteArrayOutputStream outputStream=new ByteArrayOutputStream(); XMLStreamWriter writer=StaxUtils.createXMLStreamWriter(outputStream,"utf-8"); StaxUtils.writeNode(doc,writer,true); writer.close(); String savedSchema=new String(outputStream.toByteArray(),StandardCharsets.UTF_8); assertTrue(savedSchema.contains("http://www.w3.org/2005/05/xmlmime")); SchemaImport types2SchemaImport=getImport(typesSchema.getImports(),"http://apache.org/hello_world_soap_http/types2"); Schema types2Schema=types2SchemaImport.getReferencedSchema(); assertNotNull(types2Schema); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSayHiOperation() throws Exception { setupWSDL(WSDL_PATH); PortType portType=newDef.getPortType(new QName(newDef.getTargetNamespace(),"Greeter")); Collection operations=CastUtils.cast(portType.getOperations(),Operation.class); assertEquals(4,operations.size()); Operation sayHi=portType.getOperation("sayHi","sayHiRequest","sayHiResponse"); assertNotNull(sayHi); assertEquals(sayHi.getName(),"sayHi"); Input input=sayHi.getInput(); assertNotNull(input); assertEquals("sayHiRequest",input.getName()); Message message=input.getMessage(); assertNotNull(message); assertEquals("sayHiRequest",message.getQName().getLocalPart()); assertEquals(newDef.getTargetNamespace(),message.getQName().getNamespaceURI()); assertEquals(1,message.getParts().size()); assertEquals("in",message.getPart("in").getName()); Output output=sayHi.getOutput(); assertNotNull(output); assertEquals("sayHiResponse",output.getName()); message=output.getMessage(); assertNotNull(message); assertEquals("sayHiResponse",message.getQName().getLocalPart()); assertEquals(newDef.getTargetNamespace(),message.getQName().getNamespaceURI()); assertEquals(1,message.getParts().size()); assertEquals("out",message.getPart("out").getName()); assertEquals(0,sayHi.getFaults().size()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testPingMeOperation() throws Exception { setupWSDL(WSDL_PATH); PortType portType=newDef.getPortType(new QName(newDef.getTargetNamespace(),"Greeter")); Operation pingMe=portType.getOperation("pingMe","pingMeRequest","pingMeResponse"); assertNotNull(pingMe); assertEquals("pingMe",pingMe.getName()); Input input=pingMe.getInput(); assertNotNull(input); assertEquals("pingMeRequest",input.getName()); Message message=input.getMessage(); assertNotNull(message); assertEquals("pingMeRequest",message.getQName().getLocalPart()); assertEquals(newDef.getTargetNamespace(),message.getQName().getNamespaceURI()); assertEquals(1,message.getParts().size()); assertEquals("in",message.getPart("in").getName()); Output output=pingMe.getOutput(); assertNotNull(output); assertEquals("pingMeResponse",output.getName()); message=output.getMessage(); assertNotNull(message); assertEquals("pingMeResponse",message.getQName().getLocalPart()); assertEquals(newDef.getTargetNamespace(),message.getQName().getNamespaceURI()); assertEquals(message.getParts().size(),1); assertEquals("out",message.getPart("out").getName()); assertEquals(1,pingMe.getFaults().size()); Fault fault=pingMe.getFault("pingMeFault"); assertNotNull(fault); assertEquals("pingMeFault",fault.getName()); message=fault.getMessage(); assertNotNull(message); assertEquals("pingMeFault",message.getQName().getLocalPart()); assertEquals(newDef.getTargetNamespace(),message.getQName().getNamespaceURI()); assertEquals(1,message.getParts().size()); assertEquals("faultDetail",message.getPart("faultDetail").getName()); assertNull(message.getPart("faultDetail").getTypeName()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testGreetMeOneWayOperation() throws Exception { setupWSDL(WSDL_PATH); PortType portType=newDef.getPortType(new QName(newDef.getTargetNamespace(),"Greeter")); Operation greetMeOneWay=portType.getOperation("greetMeOneWay","greetMeOneWayRequest",null); assertNotNull(greetMeOneWay); assertEquals("greetMeOneWay",greetMeOneWay.getName()); Input input=greetMeOneWay.getInput(); assertNotNull(input); assertEquals("greetMeOneWayRequest",input.getName()); Message message=input.getMessage(); assertNotNull(message); assertEquals("greetMeOneWayRequest",message.getQName().getLocalPart()); assertEquals(newDef.getTargetNamespace(),message.getQName().getNamespaceURI()); assertEquals(1,message.getParts().size()); assertEquals("in",message.getPart("in").getName()); Output output=greetMeOneWay.getOutput(); assertNull(output); assertEquals(0,greetMeOneWay.getFaults().size()); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testPortType() throws Exception { setupWSDL(WSDL_PATH); assertEquals(1,newDef.getPortTypes().size()); PortType portType=(PortType)newDef.getPortTypes().values().iterator().next(); assertNotNull(portType); assertTrue(portType.getQName().equals(new QName(newDef.getTargetNamespace(),"Greeter"))); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testDefinition() throws Exception { setupWSDL(WSDL_PATH); assertEquals(newDef.getTargetNamespace(),"http://apache.org/hello_world_soap_http"); Service serv=newDef.getService(new QName("http://apache.org/hello_world_soap_http","SOAPService")); assertNotNull(serv); assertNotNull(serv.getPort("SoapPort")); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBinding() throws Exception { setupWSDL(WSDL_PATH); assertEquals(newDef.getBindings().size(),1); Binding binding=newDef.getBinding(new QName(newDef.getTargetNamespace(),"Greeter_SOAPBinding")); assertNotNull(binding); assertEquals(4,binding.getBindingOperations().size()); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testBindingWithDifferentNamespaceImport() throws Exception { setupWSDL("wsdl2/person.wsdl"); assertEquals(newDef.getBindings().size(),1); assertTrue(newDef.getNamespace("ns3").equals("http://cxf.apache.org/samples/wsdl-first")); }

Class: org.apache.cxf.wsdl11.WSDLManagerImplTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBuildImportedWSDL() throws Exception { String wsdlUrl=getClass().getResource("hello_world_services.wsdl").toString(); WSDLManagerImpl builder=new WSDLManagerImpl(); Definition def=builder.getDefinition(wsdlUrl); assertNotNull(def); Map services=def.getServices(); assertNotNull(services); assertEquals(1,services.size()); String serviceQName="http://apache.org/hello_world/services"; Service service=(Service)services.get(new QName(serviceQName,"SOAPService")); assertNotNull(service); Map ports=service.getPorts(); assertNotNull(ports); assertEquals(1,ports.size()); Port port=service.getPort("SoapPort"); assertNotNull(port); Binding binding=port.getBinding(); assertNotNull(binding); QName bindingQName=new QName("http://apache.org/hello_world/bindings","SOAPBinding"); assertEquals(bindingQName,binding.getQName()); PortType portType=binding.getPortType(); assertNotNull(portType); QName portTypeQName=new QName("http://apache.org/hello_world","Greeter"); assertEquals(portTypeQName,portType.getQName()); Operation op1=portType.getOperation("sayHi","sayHiRequest","sayHiResponse"); assertNotNull(op1); QName messageQName=new QName("http://apache.org/hello_world/messages","sayHiRequest"); assertEquals(messageQName,op1.getInput().getMessage().getQName()); Part part=op1.getInput().getMessage().getPart("in"); assertNotNull(part); assertEquals(new QName("http://apache.org/hello_world/types","sayHi"),part.getElementName()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBuildSimpleWSDL() throws Exception { String qname="http://apache.org/hello_world_soap_http"; String wsdlUrl=getClass().getResource("hello_world.wsdl").toString(); WSDLManagerImpl builder=new WSDLManagerImpl(); Definition def=builder.getDefinition(wsdlUrl); assertNotNull(def); Map services=def.getServices(); assertNotNull(services); assertEquals(1,services.size()); Service service=(Service)services.get(new QName(qname,"SOAPService")); assertNotNull(service); Map ports=service.getPorts(); assertNotNull(ports); assertEquals(1,ports.size()); Port port=service.getPort("SoapPort"); assertNotNull(port); }

Class: org.apache.cxf.wsdl11.WSDLServiceBuilderTest

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBindingMessageInfo() throws Exception { setUpBasic(); BindingInfo bindingInfo=null; bindingInfo=serviceInfo.getBindings().iterator().next(); QName name=new QName(serviceInfo.getName().getNamespaceURI(),"sayHi"); BindingOperationInfo sayHi=bindingInfo.getOperation(name); BindingMessageInfo input=sayHi.getInput(); assertNotNull(input); assertEquals(input.getMessageInfo().getName().getLocalPart(),"sayHiRequest"); assertEquals(input.getMessageInfo().getName().getNamespaceURI(),"http://apache.org/hello_world_soap_http"); assertEquals(input.getMessageInfo().getMessageParts().size(),1); assertEquals(input.getMessageInfo().getMessageParts().get(0).getName().getLocalPart(),"in"); assertEquals(input.getMessageInfo().getMessageParts().get(0).getName().getNamespaceURI(),"http://apache.org/hello_world_soap_http"); assertTrue(input.getMessageInfo().getMessageParts().get(0).isElement()); QName elementName=input.getMessageInfo().getMessageParts().get(0).getElementQName(); assertEquals(elementName.getLocalPart(),"sayHi"); assertEquals(elementName.getNamespaceURI(),"http://apache.org/hello_world_soap_http/types"); BindingMessageInfo output=sayHi.getOutput(); assertNotNull(output); assertEquals(output.getMessageInfo().getName().getLocalPart(),"sayHiResponse"); assertEquals(output.getMessageInfo().getName().getNamespaceURI(),"http://apache.org/hello_world_soap_http"); assertEquals(output.getMessageInfo().getMessageParts().size(),1); assertEquals(output.getMessageInfo().getMessageParts().get(0).getName().getLocalPart(),"out"); assertEquals(output.getMessageInfo().getMessageParts().get(0).getName().getNamespaceURI(),"http://apache.org/hello_world_soap_http"); assertTrue(output.getMessageInfo().getMessageParts().get(0).isElement()); elementName=output.getMessageInfo().getMessageParts().get(0).getElementQName(); assertEquals(elementName.getLocalPart(),"sayHiResponse"); assertEquals(elementName.getNamespaceURI(),"http://apache.org/hello_world_soap_http/types"); assertTrue(sayHi.getFaults().size() == 0); name=new QName(serviceInfo.getName().getNamespaceURI(),"pingMe"); BindingOperationInfo pingMe=bindingInfo.getOperation(name); assertNotNull(pingMe); assertEquals(1,pingMe.getFaults().size()); BindingFaultInfo fault=pingMe.getFaults().iterator().next(); assertNotNull(fault); assertEquals(fault.getFaultInfo().getName().getLocalPart(),"pingMeFault"); assertEquals(fault.getFaultInfo().getName().getNamespaceURI(),"http://apache.org/hello_world_soap_http"); assertEquals(fault.getFaultInfo().getMessageParts().size(),1); assertEquals(fault.getFaultInfo().getMessageParts().get(0).getName().getLocalPart(),"faultDetail"); assertEquals(fault.getFaultInfo().getMessageParts().get(0).getName().getNamespaceURI(),"http://apache.org/hello_world_soap_http"); assertTrue(fault.getFaultInfo().getMessageParts().get(0).isElement()); elementName=fault.getFaultInfo().getMessageParts().get(0).getElementQName(); assertEquals(elementName.getLocalPart(),"faultDetail"); assertEquals(elementName.getNamespaceURI(),"http://apache.org/hello_world_soap_http/types"); control.verify(); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBare() throws Exception { setUpWSDL(BARE_WSDL_PATH,0); BindingInfo bindingInfo=null; bindingInfo=serviceInfo.getBindings().iterator().next(); Collection bindingOperationInfos=bindingInfo.getOperations(); assertNotNull(bindingOperationInfos); assertEquals(bindingOperationInfos.size(),1); LOG.info("the binding operation is " + bindingOperationInfos.iterator().next().getName()); QName name=new QName(serviceInfo.getName().getNamespaceURI(),"greetMe"); BindingOperationInfo greetMe=bindingInfo.getOperation(name); assertNotNull(greetMe); assertEquals("greetMe OperationInfo name error",greetMe.getName(),name); assertFalse("greetMe should be a Unwrapped operation ",greetMe.isUnwrappedCapable()); assertNotNull(serviceInfo.getXmlSchemaCollection()); control.verify(); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testNoBodyParts() throws Exception { setUpWSDL(NO_BODY_PARTS_WSDL_PATH,0); QName messageName=new QName("urn:org:apache:cxf:no_body_parts/wsdl","operation1Request"); MessageInfo mi=serviceInfo.getMessage(messageName); QName partName=new QName("urn:org:apache:cxf:no_body_parts/wsdl","mimeAttachment"); MessagePartInfo pi=mi.getMessagePart(partName); QName typeName=new QName("http://www.w3.org/2001/XMLSchema","base64Binary"); assertEquals(typeName,pi.getTypeQName()); assertNull(pi.getElementQName()); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testExtensions() throws Exception { setUpWSDL("hello_world_ext.wsdl",0); String ns="http://apache.org/hello_world_soap_http"; QName pingMeOpName=new QName(ns,"pingMe"); QName greetMeOpName=new QName(ns,"greetMe"); QName faultName=new QName(ns,"pingMeFault"); InterfaceInfo ii=serviceInfo.getInterface(); assertEquals(2,ii.getExtensionAttributes().size()); assertNotNull(ii.getExtensionAttribute(EXTENSION_ATTR_BOOLEAN)); assertNotNull(ii.getExtensionAttribute(EXTENSION_ATTR_STRING)); assertEquals(1,ii.getExtensors(UnknownExtensibilityElement.class).size()); assertEquals(EXTENSION_ELEM,ii.getExtensor(UnknownExtensibilityElement.class).getElementType()); OperationInfo oi=ii.getOperation(pingMeOpName); assertPortTypeOperationExtensions(oi,true); assertPortTypeOperationExtensions(ii.getOperation(greetMeOpName),false); assertPortTypeOperationMessageExtensions(oi,true,true,faultName); assertPortTypeOperationMessageExtensions(ii.getOperation(greetMeOpName),false,true,null); assertEquals(1,serviceInfo.getExtensionAttributes().size()); assertNotNull(serviceInfo.getExtensionAttribute(EXTENSION_ATTR_STRING)); assertEquals(1,serviceInfo.getExtensors(UnknownExtensibilityElement.class).size()); assertEquals(EXTENSION_ELEM,serviceInfo.getExtensor(UnknownExtensibilityElement.class).getElementType()); EndpointInfo ei=serviceInfo.getEndpoints().iterator().next(); assertEquals(1,ei.getExtensionAttributes().size()); assertNotNull(ei.getExtensionAttribute(EXTENSION_ATTR_STRING)); assertEquals(1,ei.getExtensors(UnknownExtensibilityElement.class).size()); assertEquals(EXTENSION_ELEM,ei.getExtensor(UnknownExtensibilityElement.class).getElementType()); BindingInfo bi=ei.getBinding(); assertEquals(1,bi.getExtensors(UnknownExtensibilityElement.class).size()); assertEquals(EXTENSION_ELEM,bi.getExtensor(UnknownExtensibilityElement.class).getElementType()); BindingOperationInfo boi=bi.getOperation(pingMeOpName); assertBindingOperationExtensions(boi,true); assertBindingOperationExtensions(bi.getOperation(greetMeOpName),false); assertBindingOperationMessageExtensions(boi,true,true,faultName); assertBindingOperationMessageExtensions(bi.getOperation(greetMeOpName),false,true,null); control.verify(); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testServiceInfo() throws Exception { setUpBasic(); assertEquals("SOAPService",serviceInfo.getName().getLocalPart()); assertEquals("http://apache.org/hello_world_soap_http",serviceInfo.getName().getNamespaceURI()); assertEquals("http://apache.org/hello_world_soap_http",serviceInfo.getTargetNamespace()); assertTrue(serviceInfo.getProperty(WSDLServiceBuilder.WSDL_DEFINITION) == def); assertTrue(serviceInfo.getProperty(WSDLServiceBuilder.WSDL_SERVICE) == service); assertEquals("Incorrect number of endpoints",1,serviceInfo.getEndpoints().size()); EndpointInfo ei=serviceInfo.getEndpoint(new QName("http://apache.org/hello_world_soap_http","SoapPort")); assertNotNull(ei); assertEquals("http://schemas.xmlsoap.org/wsdl/soap/",ei.getTransportId()); assertNotNull(ei.getBinding()); control.verify(); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testParameterOrder2() throws Exception { setUpWSDL("header2.wsdl",0); String ns="http://apache.org/header2"; OperationInfo operation=serviceInfo.getInterface().getOperation(new QName(ns,"headerMethod")); assertNotNull(operation); List parts=operation.getInput().getMessageParts(); assertNotNull(parts); assertEquals(2,parts.size()); assertEquals("header_info",parts.get(0).getName().getLocalPart()); assertEquals("the_request",parts.get(1).getName().getLocalPart()); control.verify(); }

EqualityVerifier 
@Test public void testInterfaceInfo() throws Exception { setUpBasic(); assertEquals("Greeter",serviceInfo.getInterface().getName().getLocalPart()); control.verify(); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSchema() throws Exception { setUpBasic(); SchemaCollection schemas=serviceInfo.getXmlSchemaCollection(); assertNotNull(schemas); assertEquals(1,serviceInfo.getSchemas().size()); SchemaInfo schemaInfo=serviceInfo.getSchemas().iterator().next(); assertNotNull(schemaInfo); assertEquals(schemaInfo.getNamespaceURI(),"http://apache.org/hello_world_soap_http/types"); assertEquals(schemas.read(schemaInfo.getElement()).getTargetNamespace(),"http://apache.org/hello_world_soap_http/types"); Schema schema=EndpointReferenceUtils.getSchema(serviceInfo); assertNotNull(schema); control.verify(); }

EqualityVerifier 
@Test public void testBuildServiceWithWrongEndpointName() throws Exception { setUpWSDL(WSDL_PATH,0); buildService(new QName("http://apache.org/hello_world_soap_http","NoExitSoapPort")); assertEquals("Should not build any serviceInfo.",0,serviceInfos.size()); assertEquals("Should not build any serviceInfo.",null,serviceInfo); }

EqualityVerifier 
@Test public void testMultiPorttype() throws Exception { setUpWSDL(MULTIPORT_WSDL_PATH,0); assertEquals(2,serviceInfos.size()); control.verify(); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testOperationInfo() throws Exception { setUpBasic(); QName name=new QName(serviceInfo.getName().getNamespaceURI(),"sayHi"); assertEquals(4,serviceInfo.getInterface().getOperations().size()); OperationInfo sayHi=serviceInfo.getInterface().getOperation(new QName(serviceInfo.getName().getNamespaceURI(),"sayHi")); assertNotNull(sayHi); assertEquals(sayHi.getName(),name); assertFalse(sayHi.isOneWay()); assertTrue(sayHi.hasInput()); assertTrue(sayHi.hasOutput()); assertNull(sayHi.getParameterOrdering()); name=new QName(serviceInfo.getName().getNamespaceURI(),"greetMe"); OperationInfo greetMe=serviceInfo.getInterface().getOperation(name); assertNotNull(greetMe); assertEquals(greetMe.getName(),name); assertFalse(greetMe.isOneWay()); assertTrue(greetMe.hasInput()); assertTrue(greetMe.hasOutput()); List inParts=greetMe.getInput().getMessageParts(); assertEquals(1,inParts.size()); MessagePartInfo part=inParts.get(0); assertNotNull(part.getXmlSchema()); assertTrue(part.getXmlSchema() instanceof XmlSchemaElement); List outParts=greetMe.getOutput().getMessageParts(); assertEquals(1,outParts.size()); part=outParts.get(0); assertNotNull(part.getXmlSchema()); assertTrue(part.getXmlSchema() instanceof XmlSchemaElement); assertTrue("greatMe should be wrapped",greetMe.isUnwrappedCapable()); OperationInfo greetMeUnwrapped=greetMe.getUnwrappedOperation(); assertNotNull(greetMeUnwrapped.getInput()); assertNotNull(greetMeUnwrapped.getOutput()); assertEquals("wrapped part not set",1,greetMeUnwrapped.getInput().size()); assertEquals("wrapped part not set",1,greetMeUnwrapped.getOutput().size()); assertEquals("wrapper part name wrong","requestType",greetMeUnwrapped.getInput().getMessagePartByIndex(0).getName().getLocalPart()); assertEquals("wrapper part type name wrong","MyStringType",greetMeUnwrapped.getInput().getMessagePartByIndex(0).getTypeQName().getLocalPart()); assertEquals("wrapper part name wrong","responseType",greetMeUnwrapped.getOutput().getMessagePartByIndex(0).getName().getLocalPart()); assertEquals("wrapper part type name wrong","string",greetMeUnwrapped.getOutput().getMessagePartByIndex(0).getTypeQName().getLocalPart()); name=new QName(serviceInfo.getName().getNamespaceURI(),"greetMeOneWay"); OperationInfo greetMeOneWay=serviceInfo.getInterface().getOperation(name); assertNotNull(greetMeOneWay); assertEquals(greetMeOneWay.getName(),name); assertTrue(greetMeOneWay.isOneWay()); assertTrue(greetMeOneWay.hasInput()); assertFalse(greetMeOneWay.hasOutput()); OperationInfo greetMeOneWayUnwrapped=greetMeOneWay.getUnwrappedOperation(); assertNotNull(greetMeOneWayUnwrapped); assertNotNull(greetMeOneWayUnwrapped.getInput()); assertNull(greetMeOneWayUnwrapped.getOutput()); assertEquals("wrapped part not set",1,greetMeOneWayUnwrapped.getInput().size()); assertEquals(new QName("http://apache.org/hello_world_soap_http/types","requestType"),greetMeOneWayUnwrapped.getInput().getMessagePartByIndex(0).getConcreteName()); name=new QName(serviceInfo.getName().getNamespaceURI(),"pingMe"); OperationInfo pingMe=serviceInfo.getInterface().getOperation(name); assertNotNull(pingMe); assertEquals(pingMe.getName(),name); assertFalse(pingMe.isOneWay()); assertTrue(pingMe.hasInput()); assertTrue(pingMe.hasOutput()); assertNull(serviceInfo.getInterface().getOperation(new QName("what ever"))); control.verify(); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testParameterOrder() throws Exception { String ns="http://apache.org/hello_world_xml_http/bare"; setUpWSDL("hello_world_xml_bare.wsdl",0); OperationInfo operation=serviceInfo.getInterface().getOperation(new QName(ns,"testTriPart")); assertNotNull(operation); List parts=operation.getInput().getMessageParts(); assertNotNull(parts); assertEquals(3,parts.size()); assertEquals("in3",parts.get(0).getName().getLocalPart()); assertEquals("in1",parts.get(1).getName().getLocalPart()); assertEquals("in2",parts.get(2).getName().getLocalPart()); List order=operation.getParameterOrdering(); assertNotNull(order); assertEquals(3,order.size()); assertEquals("in1",order.get(0)); assertEquals("in3",order.get(1)); assertEquals("in2",order.get(2)); parts=operation.getInput().getOrderedParts(order); assertNotNull(parts); assertEquals(3,parts.size()); assertEquals("in1",parts.get(0).getName().getLocalPart()); assertEquals("in3",parts.get(1).getName().getLocalPart()); assertEquals("in2",parts.get(2).getName().getLocalPart()); operation=serviceInfo.getInterface().getOperation(new QName(ns,"testTriPartNoOrder")); assertNotNull(operation); parts=operation.getInput().getMessageParts(); assertNotNull(parts); assertEquals(3,parts.size()); assertEquals("in3",parts.get(0).getName().getLocalPart()); assertEquals("in1",parts.get(1).getName().getLocalPart()); assertEquals("in2",parts.get(2).getName().getLocalPart()); control.verify(); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBindingOperationInfo() throws Exception { setUpBasic(); BindingInfo bindingInfo=null; bindingInfo=serviceInfo.getBindings().iterator().next(); Collection bindingOperationInfos=bindingInfo.getOperations(); assertNotNull(bindingOperationInfos); assertEquals(bindingOperationInfos.size(),4); LOG.info("the binding operation is " + bindingOperationInfos.iterator().next().getName()); QName name=new QName(serviceInfo.getName().getNamespaceURI(),"sayHi"); BindingOperationInfo sayHi=bindingInfo.getOperation(name); assertNotNull(sayHi); assertEquals(sayHi.getName(),name); name=new QName(serviceInfo.getName().getNamespaceURI(),"greetMe"); BindingOperationInfo greetMe=bindingInfo.getOperation(name); assertNotNull(greetMe); assertEquals(greetMe.getName(),name); name=new QName(serviceInfo.getName().getNamespaceURI(),"greetMeOneWay"); BindingOperationInfo greetMeOneWay=bindingInfo.getOperation(name); assertNotNull(greetMeOneWay); assertEquals(greetMeOneWay.getName(),name); name=new QName(serviceInfo.getName().getNamespaceURI(),"pingMe"); BindingOperationInfo pingMe=bindingInfo.getOperation(name); assertNotNull(pingMe); assertEquals(pingMe.getName(),name); control.verify(); }

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testBindingInfo() throws Exception { setUpBasic(); BindingInfo bindingInfo=null; assertEquals(1,serviceInfo.getBindings().size()); bindingInfo=serviceInfo.getBindings().iterator().next(); assertNotNull(bindingInfo); assertEquals(bindingInfo.getInterface().getName().getLocalPart(),"Greeter"); assertEquals(bindingInfo.getName().getLocalPart(),"Greeter_SOAPBinding"); assertEquals(bindingInfo.getName().getNamespaceURI(),"http://apache.org/hello_world_soap_http"); control.verify(); }

Class: org.apache.cxf.wsn.WsnBrokerTest

InternalCallVerifier EqualityVerifier PublicFieldVerifier 
@Test public void testPublisher() throws Exception { TestConsumer consumerCallback=new TestConsumer(); Consumer consumer=new Consumer(consumerCallback,"http://localhost:" + port2 + "/test/consumer"); Subscription subscription=notificationBroker.subscribe(consumer,"myTopic"); PublisherCallback publisherCallback=new PublisherCallback(); Publisher publisher=new Publisher(publisherCallback,"http://localhost:" + port2 + "/test/publisher"); Registration registration=notificationBroker.registerPublisher(publisher,"myTopic"); synchronized (consumerCallback.notifications) { notificationBroker.notify(publisher,"myTopic",new JAXBElement(new QName("urn:test:org","foo"),String.class,"bar")); consumerCallback.notifications.wait(1000000); } assertEquals(1,consumerCallback.notifications.size()); NotificationMessageHolderType message=consumerCallback.notifications.get(0); assertEquals(WSNHelper.getInstance().getWSAAddress(subscription.getEpr()),WSNHelper.getInstance().getWSAAddress(message.getSubscriptionReference())); assertEquals(WSNHelper.getInstance().getWSAAddress(publisher.getEpr()),WSNHelper.getInstance().getWSAAddress(message.getProducerReference())); subscription.unsubscribe(); registration.destroy(); publisher.stop(); consumer.stop(); }

InternalCallVerifier EqualityVerifier PublicFieldVerifier 
@Test public void testBroker() throws Exception { TestConsumer callback=new TestConsumer(); Consumer consumer=new Consumer(callback,"http://localhost:" + port2 + "/test/consumer"); Subscription subscription=notificationBroker.subscribe(consumer,"myTopic"); synchronized (callback.notifications) { notificationBroker.notify("myTopic",new JAXBElement(new QName("urn:test:org","foo"),String.class,"bar")); callback.notifications.wait(1000000); } assertEquals(1,callback.notifications.size()); NotificationMessageHolderType message=callback.notifications.get(0); assertEquals(WSNHelper.getInstance().getWSAAddress(subscription.getEpr()),WSNHelper.getInstance().getWSAAddress(message.getSubscriptionReference())); subscription.unsubscribe(); consumer.stop(); }

BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier PublicFieldVerifier HybridVerifier 
@Test public void testPublisherCustomType() throws Exception { notificationBroker.setExtraClasses(CustomType.class); TestConsumer consumerCallback=new TestConsumer(); Consumer consumer=new Consumer(consumerCallback,"http://localhost:" + port2 + "/test/consumer",CustomType.class); Subscription subscription=notificationBroker.subscribe(consumer,"myTopic"); PublisherCallback publisherCallback=new PublisherCallback(); Publisher publisher=new Publisher(publisherCallback,"http://localhost:" + port2 + "/test/publisher"); Registration registration=notificationBroker.registerPublisher(publisher,"myTopic"); synchronized (consumerCallback.notifications) { notificationBroker.notify(publisher,"myTopic",new CustomType(1,2)); consumerCallback.notifications.wait(1000000); } assertEquals(1,consumerCallback.notifications.size()); NotificationMessageHolderType message=consumerCallback.notifications.get(0); assertEquals(WSNHelper.getInstance().getWSAAddress(subscription.getEpr()),WSNHelper.getInstance().getWSAAddress(message.getSubscriptionReference())); assertEquals(WSNHelper.getInstance().getWSAAddress(publisher.getEpr()),WSNHelper.getInstance().getWSAAddress(message.getProducerReference())); assertNotNull(message.getMessage().getAny()); assertTrue(message.getMessage().getAny().getClass().getName(),message.getMessage().getAny() instanceof CustomType); subscription.unsubscribe(); registration.destroy(); publisher.stop(); consumer.stop(); }

InternalCallVerifier EqualityVerifier PublicFieldVerifier 
@Test public void testNullPublisherReference() throws Exception { TestConsumer consumerCallback=new TestConsumer(); Consumer consumer=new Consumer(consumerCallback,"http://localhost:" + port2 + "/test/consumer"); Subscription subscription=notificationBroker.subscribe(consumer,"myTopicNullEPR"); Publisher publisher=new Publisher(null,null); Registration registration=notificationBroker.registerPublisher(publisher,"myTopicNullEPR",false); synchronized (consumerCallback.notifications) { notificationBroker.notify(publisher,"myTopicNullEPR",new JAXBElement(new QName("urn:test:org","foo"),String.class,"bar")); consumerCallback.notifications.wait(1000000); } assertEquals(1,consumerCallback.notifications.size()); NotificationMessageHolderType message=consumerCallback.notifications.get(0); assertEquals(WSNHelper.getInstance().getWSAAddress(subscription.getEpr()),WSNHelper.getInstance().getWSAAddress(message.getSubscriptionReference())); subscription.unsubscribe(); registration.destroy(); publisher.stop(); consumer.stop(); }

Class: org.apache.cxf.xkms.itests.handlers.validator.ValidatorCRLTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testRevokedCertificate() throws CertificateException { X509Certificate wss40Certificate=readCertificate("wss40rev.cer"); ValidateRequestType request=prepareValidateXKMSRequest(wss40Certificate); StatusType result=doValidate(request); Assert.assertEquals(KeyBindingEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_INVALID,result.getStatusValue()); Assert.assertFalse(result.getInvalidReason().isEmpty()); Assert.assertEquals(ReasonEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_ISSUER_TRUST.value(),result.getInvalidReason().get(0)); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testValidCertWithCRL() throws CertificateException { X509Certificate wss40Certificate=readCertificate("wss40.cer"); ValidateRequestType request=prepareValidateXKMSRequest(wss40Certificate); StatusType result=doValidate(request); Assert.assertEquals(KeyBindingEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_VALID,result.getStatusValue()); Assert.assertFalse(result.getValidReason().isEmpty()); Assert.assertEquals(ReasonEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_VALIDITY_INTERVAL.value(),result.getValidReason().get(0)); Assert.assertEquals(ReasonEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_ISSUER_TRUST.value(),result.getValidReason().get(1)); }

Class: org.apache.cxf.xkms.itests.handlers.validator.ValidatorTest

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testWss40DirectTrustNegative() throws JAXBException, CertificateException { X509Certificate wss40Certificate=readCertificate("wss40.cer"); ValidateRequestType request=prepareValidateXKMSRequest(wss40Certificate); request.getQueryKeyBinding().getKeyUsage().add(KeyUsageEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_SIGNATURE); StatusType result=doValidate(request); Assert.assertEquals(KeyBindingEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_INVALID,result.getStatusValue()); Assert.assertFalse(result.getInvalidReason().isEmpty()); Assert.assertEquals(XKMSConstants.DIRECT_TRUST_VALIDATION,result.getInvalidReason().get(0)); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testDaveSignedByAliceSginedByRootIsValid() throws JAXBException, CertificateException { X509Certificate daveCertificate=readCertificate("dave.cer"); ValidateRequestType request=prepareValidateXKMSRequest(daveCertificate); StatusType result=doValidate(request); Assert.assertEquals(KeyBindingEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_VALID,result.getStatusValue()); Assert.assertFalse(result.getValidReason().isEmpty()); Assert.assertEquals(ReasonEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_VALIDITY_INTERVAL.value(),result.getValidReason().get(0)); Assert.assertEquals(ReasonEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_ISSUER_TRUST.value(),result.getValidReason().get(1)); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testSelfSignedCertOscarIsNotValid() throws JAXBException, CertificateException { X509Certificate oscarCertificate=readCertificate("oscar.cer"); ValidateRequestType request=prepareValidateXKMSRequest(oscarCertificate); StatusType result=doValidate(request); Assert.assertEquals(KeyBindingEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_INVALID,result.getStatusValue()); Assert.assertFalse(result.getInvalidReason().isEmpty()); Assert.assertEquals(ReasonEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_ISSUER_TRUST.value(),result.getInvalidReason().get(0)); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testRootCertIsValid() throws CertificateException { X509Certificate rootCertificate=readCertificate("trusted_cas/root.cer"); ValidateRequestType request=prepareValidateXKMSRequest(rootCertificate); StatusType result=doValidate(request); Assert.assertEquals(KeyBindingEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_VALID,result.getStatusValue()); Assert.assertFalse(result.getValidReason().isEmpty()); Assert.assertEquals(ReasonEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_VALIDITY_INTERVAL.value(),result.getValidReason().get(0)); Assert.assertEquals(ReasonEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_ISSUER_TRUST.value(),result.getValidReason().get(1)); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testDaveDirectTrust() throws JAXBException, CertificateException { X509Certificate daveCertificate=readCertificate("dave.cer"); ValidateRequestType request=prepareValidateXKMSRequest(daveCertificate); request.getQueryKeyBinding().getKeyUsage().add(KeyUsageEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_SIGNATURE); StatusType result=doValidate(request); Assert.assertEquals(KeyBindingEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_VALID,result.getStatusValue()); Assert.assertFalse(result.getValidReason().isEmpty()); Assert.assertEquals(ReasonEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_VALIDITY_INTERVAL.value(),result.getValidReason().get(0)); Assert.assertEquals(ReasonEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_ISSUER_TRUST.value(),result.getValidReason().get(1)); Assert.assertEquals(XKMSConstants.DIRECT_TRUST_VALIDATION,result.getValidReason().get(2)); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testAliceSignedByRootIsValid() throws JAXBException, CertificateException { X509Certificate aliceCertificate=readCertificate("cas/alice.cer"); ValidateRequestType request=prepareValidateXKMSRequest(aliceCertificate); StatusType result=doValidate(request); Assert.assertEquals(KeyBindingEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_VALID,result.getStatusValue()); Assert.assertFalse(result.getValidReason().isEmpty()); Assert.assertEquals(ReasonEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_VALIDITY_INTERVAL.value(),result.getValidReason().get(0)); Assert.assertEquals(ReasonEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_ISSUER_TRUST.value(),result.getValidReason().get(1)); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testExpiredCertIsNotValid() throws CertificateException { X509Certificate expiredCertificate=readCertificate("expired.cer"); ValidateRequestType request=prepareValidateXKMSRequest(expiredCertificate); StatusType result=doValidate(request); Assert.assertEquals(KeyBindingEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_INVALID,result.getStatusValue()); Assert.assertFalse(result.getInvalidReason().isEmpty()); Assert.assertEquals(ReasonEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_VALIDITY_INTERVAL.value(),result.getInvalidReason().get(0)); }

Class: org.apache.cxf.xkms.itests.service.XKMSServiceTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testEmptyRegister() throws URISyntaxException, Exception { RegisterRequestType request=new RegisterRequestType(); setGenericRequestParams(request); RegisterResultType result=xkmsService.register(request); Assert.assertEquals(ResultMajorEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_SENDER.value(),result.getResultMajor()); Assert.assertEquals(ResultMinorEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_FAILURE.value(),result.getResultMinor()); ResultDetails message=(ResultDetails)result.getMessageExtension().get(0); Assert.assertEquals("org.apache.cxf.xkms.model.xkms.PrototypeKeyBindingType must be set",message.getDetails()); }

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testRegisterWithoutKey() throws URISyntaxException, Exception { RegisterRequestType request=new RegisterRequestType(); setGenericRequestParams(request); PrototypeKeyBindingType binding=new PrototypeKeyBindingType(); KeyInfoType keyInfo=new KeyInfoType(); binding.setKeyInfo(keyInfo); request.setPrototypeKeyBinding(binding); RegisterResultType result=xkmsService.register(request); Assert.assertEquals(ResultMajorEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_SENDER.value(),result.getResultMajor()); Assert.assertEquals(ResultMinorEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_FAILURE.value(),result.getResultMinor()); }

Class: org.apache.cxf.xkms.itests.service.XKRSSDisableTest

APIUtilityVerifier InternalCallVerifier EqualityVerifier 
@Test public void testRegisterShouldBeDisabled(){ RegisterRequestType request=new RegisterRequestType(); request.setService(XKMSConstants.XKMS_ENDPOINT_NAME); request.setId(UUID.randomUUID().toString()); RegisterResultType result=xkmsService.register(request); Assert.assertEquals(ResultMajorEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_SENDER.value(),result.getResultMajor()); Assert.assertEquals(ResultMinorEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_MESSAGE_NOT_SUPPORTED.value(),result.getResultMinor()); ResultDetails message=(ResultDetails)result.getMessageExtension().get(0); Assert.assertEquals("XKRSS Operations are disabled",message.getDetails()); }

Class: org.apache.cxf.xkms.x509.repo.file.FileCertificateRepoTest

InternalCallVerifier EqualityVerifier 
@Test public void testConvertDnForFileSystem() throws CertificateException { String convertedName=new FileCertificateRepo("src/test/resources/store1").convertIdForFileSystem(EXAMPLE_SUBJECT_DN); Assert.assertEquals("CN-www.issuer.com_L-CGN_ST-NRW_C-DE_O-Issuer",convertedName); }

APIUtilityVerifier BooleanVerifier InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testSaveAndFind() throws CertificateException, IOException, URISyntaxException { File storageDir=new File("target/teststore1"); storageDir.mkdirs(); FileCertificateRepo fileRegisterHandler=new FileCertificateRepo("target/teststore1"); InputStream is=this.getClass().getResourceAsStream("/store1/" + EXPECTED_CERT_FILE_NAME); if (is == null) { throw new RuntimeException("Can not find path " + is + " in classpath"); } X509Certificate cert=loadTestCert(is); UseKeyWithType key=new UseKeyWithType(); key.setApplication(Applications.PKIX.getUri()); key.setIdentifier(EXAMPLE_SUBJECT_DN); fileRegisterHandler.saveCertificate(cert,key); File certFile=new File(storageDir,fileRegisterHandler.getCertPath(cert,key)); Assert.assertTrue("Cert file " + certFile + " should exist",certFile.exists()); FileInputStream fis=new FileInputStream(certFile); X509Certificate outCert=loadTestCert(fis); Assert.assertEquals(cert,outCert); X509Certificate resultCert=fileRegisterHandler.findBySubjectDn(EXAMPLE_SUBJECT_DN); Assert.assertNotNull(resultCert); }

Class: org.apache.cxf.xkms.x509.repo.ldap.LDAPCertificateRepoTest

InternalCallVerifier EqualityVerifier IgnoredMethod HybridVerifier 
@Test @Ignore public void testFindServiceCert() throws URISyntaxException, NamingException, CertificateException { CertificateRepo persistenceManager=createLdapCertificateRepo(); String serviceUri="cn=http:\\/\\/myservice.apache.org\\/MyServiceName,ou=services"; X509Certificate cert=persistenceManager.findByServiceName(serviceUri); Assert.assertEquals(EXPECTED_SUBJECT_DN,cert.getSubjectDN().toString()); }

Class: org.apache.cxf.xkms.x509.validator.DateValidatorTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void validateDateExpired() throws JAXBException { StatusType result=processRequest("/validateRequestExpired.xml"); Assert.assertEquals(result.getStatusValue(),KeyBindingEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_INVALID); Assert.assertFalse(result.getInvalidReason().isEmpty()); Assert.assertEquals(ReasonEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_VALIDITY_INTERVAL.value(),result.getInvalidReason().get(0)); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void validateDateOK() throws JAXBException { StatusType result=processRequest("/validateRequestOK.xml"); Assert.assertEquals(KeyBindingEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_VALID,result.getStatusValue()); Assert.assertFalse(result.getValidReason().isEmpty()); Assert.assertEquals(ReasonEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_VALIDITY_INTERVAL.value(),result.getValidReason().get(0)); }

Class: org.apache.cxf.xkms.x509.validator.TrustedAuthorityValidatorTest

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testSelfSignedCertOscarIsNotValid() throws JAXBException, CertificateException { StatusType result=processRequest("validateRequestInvalidOscar.xml"); Assert.assertEquals(result.getStatusValue(),KeyBindingEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_INVALID); Assert.assertFalse(result.getInvalidReason().isEmpty()); Assert.assertEquals(ReasonEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_ISSUER_TRUST.value(),result.getInvalidReason().get(0)); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testRootCertIsValid() throws JAXBException, CertificateException { StatusType result=processRequest("validateRequestOKRoot.xml"); Assert.assertEquals(KeyBindingEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_VALID,result.getStatusValue()); Assert.assertFalse(result.getValidReason().isEmpty()); Assert.assertEquals(ReasonEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_ISSUER_TRUST.value(),result.getValidReason().get(0)); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testAliceSignedByRootIsValid() throws JAXBException, CertificateException { StatusType result=processRequest("validateRequestOKAlice.xml"); Assert.assertEquals(KeyBindingEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_VALID,result.getStatusValue()); Assert.assertFalse(result.getValidReason().isEmpty()); Assert.assertEquals(ReasonEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_ISSUER_TRUST.value(),result.getValidReason().get(0)); }

BooleanVerifier InternalCallVerifier EqualityVerifier HybridVerifier 
@Test public void testDaveSignedByAliceSginedByRootIsValid() throws JAXBException, CertificateException { StatusType result=processRequest("validateRequestOKDave.xml"); Assert.assertEquals(KeyBindingEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_VALID,result.getStatusValue()); Assert.assertFalse(result.getValidReason().isEmpty()); Assert.assertEquals(ReasonEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_ISSUER_TRUST.value(),result.getValidReason().get(0)); }

Class: org.apache.cxf.xmlbeans.MultipleSchemaInNSTest

APIUtilityVerifier EqualityVerifier 
@Test public void testWSDL() throws Exception { Document wsdl=getWSDLDocument("MultipleSchemaService"); addNamespace("xsd",Constants.URI_2001_SCHEMA_XSD); NodeList list=assertValid("//xsd:schema[@targetNamespace='" + ns + "']",wsdl); assertEquals(StaxUtils.toString(wsdl),3,list.getLength()); assertValid("//xsd:import[@namespace='" + ns + "']",list.item(0)); assertValid("//xsd:import[@namespace='" + ns + "']",list.item(0)); assertValid("//xsd:import[@namespace='" + ns + "']",list.item(1)); assertValid("//xsd:import[@namespace='" + ns + "']",list.item(2)); assertInvalid("//xsd:import[@namespace='" + ns + "']/@schemaLocation",list.item(1)); assertInvalid("//xsd:import[@namespace='" + ns + "']/@schemaLocation",list.item(2)); }

Class: org.apache.cxf.xmlbeans.WrappedStyleTest

InternalCallVerifier EqualityVerifier NullVerifier HybridVerifier 
@Test public void testParams() throws Exception { String ns="urn:TestService"; OperationInfo op=endpoint.getEndpoint().getService().getServiceInfos().get(0).getInterface().getOperation(new QName(ns,"GetWeatherByZipCode")); assertNotNull(op); MessagePartInfo info=op.getUnwrappedOperation().getInput().getMessagePart(0); assertEquals(new QName("http://cxf.apache.org/xmlbeans","request"),info.getElementQName()); }

Class: org.apache.cxf.xmlbeans.XMLBeansServiceTest

EqualityVerifier 
@Test public void testAnyWSDLNoDupRootRefElements() throws Exception { Node wsdl=getWSDLDocument("TestService"); String xpathString="/wsdl:definitions/wsdl:types//xsd:schema/xsd:element[@name='trouble']"; addNamespace("wsdl",WSDLConstants.NS_WSDL11); addNamespace("wsdlsoap",WSDLConstants.NS_SOAP11); addNamespace("xsd",Constants.URI_2001_SCHEMA_XSD); addNamespace("s",Constants.URI_2001_SCHEMA_XSD); assertEquals(1,assertValid(xpathString,wsdl).getLength()); }